Shopify / shopify-app-bridge

https://shopify.dev/docs/api/app-bridge
88 stars 9 forks source link

Strange ResourcePicker query / filter issue #35

Closed derrickrc closed 7 months ago

derrickrc commented 3 years ago

I have a merchant whose product title convention uses a # symbol followed by the product number. She showed me instances where she would search for products using my app, and incorrect products would show up first at the top. In diving deeper, I realized this was because she had the # symbol in certain product descriptions as well- however, it's not doing an exact match in this case.

For example, she is trying to search for a product whose title starts with "#8". When she searches for #8, instead at the top it shows products with this as the description / body:

Sodium carbonate (processing aid, CAS #497-19-8), sodium percarbonate (oxidant, CAS #15630-89-4), sodium citrate (chelating agent, CAS# 6132-04-03), Itaconix CHT 122 (chelating agent, CAS #1052620-22-0), alcohol alkoxylate (surfactant, trade secret), polycarboxylate sodium salt (polymer, trade secret), Subtilisin, (Protease enzyme, CAS #9014-01-01), sodium metasilicate anhydrous (processing aid, CAS# 6834-92-0), tetraacethylenediamine (TAED) (oxidant, CAS #10543-57-4), alpha amylase (enzyme, CAS #9000-90-2), polyvinyl alcohol film (PVOH) (CAS #9002-89-5, biodegradable water soluble film). Denotes plant or mineral origin.

It has # symbols, but no "#8" so I'm confused as to the search behavior.

Similarly, per this thread I thought you could prepend "title:" and have it only search titles, but it doesn't seem to work (meanwhile, sku: and product_type: do).

henrytao-me commented 3 years ago

Hi @derrickrc , we are looking into this and should post an update soon.

henrytao-me commented 3 years ago

Hi @derrickrc,

About ResourcePicker, when you type in the search field, it will return results from all fields, not just from the title. That's why you see results that doesn't have #8 in the title. To specify that you want to look for title, you can type title:#8, this will return exact match. To return relative match, you can type title:#8*, it will return anything contains #8 in the title only.

From the graphql definition, you can use the same logic for any supported filter parameters like tag, sku,.... https://community.shopify.com/c/Shopify-APIs-SDKs/shopify-App-Bridge-Product-Resource-Picker-search-by-collection/m-p/611695/highlight/true#M41562

I hope this will help your merchant in the meantime. The # symbol is treated specially on the server. We are looking into it.

derrickrc commented 3 years ago

Hi @henrytao-me thanks a lot for the quick response! That's the thing though, prepending title: doesn't work (while sku: and product_type: do). Here is a video showing the behavior: https://photos.app.goo.gl/rhs3k5g2ab44AQo7A

henrytao-me commented 3 years ago

The video is pretty blurry at the begining. I think you were trying to do title:#something. For title:avocado, as I mentioned this is doing exact match. Obviously, you don't have any products with title is exactly avocado. You can try title:avocado*.

limoniapps commented 3 years ago

@henrytao-me while the query language is certainly powerful it cannot be reasonably expected from a user of an app to understand that they need to type title:avocado* when they want to search for avocado. Is it not possible to define which fields should be queried and whether to accept only exact matches or not in the ResourcePicker configuration?

henrytao-me commented 3 years ago

I agree with you. We are working on fixing it. In the meantime, you can use above workaround. 🙇

derrickrc commented 3 years ago

Thanks @henrytao-me !

derrickrc commented 3 years ago

@henrytao-me any updates on this? Thank you.

iwoodruff commented 7 months ago

Hey @derrickrc we're always looking for ways to improve the pickers & I've taken a note that GQL query syntax is fine for developers but not intuitive for merchants. it's a compelling case for simplification – i'm going to close this issue for now

(also i'm jealous of how clicky your keyboard is in that video)