Right API to search by title

Andrew_Smith5
Shopify Partner
11 0 2

As per this thread https://community.shopify.com/c/Shopify-APIs-SDKs/Right-API-to-search-products-by-title/m-p/989241#M...

 

Using the new pagination method on the /admin/api/2020-10/products.json?title=WORD does not return any results (it returns a 200 response with an empty array, so I know authentication is working, similarly if I remove the title=WORD parameter then products are returned so I know that's working too).

I've started a new thread as the last one was marked Soved so I don't think people will read it.

If I try /admin/products.json?title=WORD then everything works, but this doesn't have the paginated results so I don't want to build an API against it as it'll be removed soon.

I feel like I'm missing something obvious. Any suggestions?

Replies 13 (13)
_JB
Shopify Staff
Shopify Staff
835 99 207

Hey @Andrew_Smith5,

The behaviour should be the same regardless of API version. Can you kindly share the X-Request-ID value from the response headers of one of your calls that's returning an empty array? I'll use this to check our logs for more information about why the response is empty for you.

JB | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Andrew_Smith5
Shopify Partner
11 0 2

Sure, thanks for the response:

 

Not working: https://DOMAIN.myshopify.com/admin/api/2020-10/products.json?title=WORD

 

7999e5d2-8425-4071-98ea-5a2c0e67f59d

 

Working: https://DOMAIN.myshopify.com/admin/products.json?title=WORD

421135da-fcd7-4dca-8e2a-56b90d794132

Thanks.

Andrew_Smith5
Shopify Partner
11 0 2

Hi @_JB 

 

Do you have an update on this? Sorry to push you, but the plussupport email has told me the only support I can get it on this forum and this is holding up my work now.


Thanks.

Greg_Kujawa
Shopify Partner
1020 83 262

Testing it out here I had the same outcome. The URI that doesn't specify the API version returned products based on the title query parameter, while the URI that specified the 2020-10 API version returned no records. Screen shots below. The "good" request ID is 855d258c-f79f-4703-8d7c-74c91c0fcc46, while the "bad" request ID is "6b4dc7f2-2542-4bd3-91aa-d56c89e94f56". @_JB any chance you can take a peek at these?

good.pngbad.png

Andrew_Smith5
Shopify Partner
11 0 2

Thank you @Greg_Kujawa  for confirming my findings.

@_JBdo you have any news for us?

_JB
Shopify Staff
Shopify Staff
835 99 207

Hi All,

We're investigating now. I'll be back in touch soon with an update.

JB | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Andrew_Smith5
Shopify Partner
11 0 2

Hi @_JB 

Have you had any luck with this? I really need to get this resolved.

 

Greg_Kujawa
Shopify Partner
1020 83 262

Hard telling, but one thing I _do_ know is that the GraphQL API will allow freetext searching for products by title. And testing it out I found that it is consistent regardless of the API version that's being hit.

Example below.

1.png

 

UPDATE: Well although the GQL queries by title are consistent across API versions it doesn't necessarily mean they are reliable. In my example about I am querying for any products with chain in the title. In my test shop there are two products with only chain in the title. They didn't appear in the response set. 

So I tried this GQL request.

{
  products(first: 10, query: "title:*chain* OR title:chain") {
    edges {
      node {
        id
        title
      }
    }
  }
}

 

Unfortunately the two products with only chain in the title still didn't appear. *sigh* 

Andrew_Smith5
Shopify Partner
11 0 2

@_JB 

I've tried this with the latest API version 2021-01 and get the exact same behaviour.

Can I please get an update on this?

_JB
Shopify Staff
Shopify Staff
835 99 207

Hi All,

We've done some digging here and have been able to clarify what's happening. This behaviour is actually expected, and was introduced in the 2019-07 API version.

@Andrew_Smith5  your calls are being sent without an API version, so in that case the system is supposed to automatically serve the lowest version (which right now is 2020-04). At this point I'm not 100% sure why you're seeing deprecated behaviour when the version isn't included, since 2019-07 has been fully deprecated this behaviour shouldn't be available to anyone. I'll be raising this with our devs as they'll likely need to make a change to ensure this is consistent everywhere, however I can confirm the expected behaviour requires either the complete title or use of a wildcard if you want to return partial matches.

JB | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Andrew_Smith5
Shopify Partner
11 0 2

@_JB 

 

Thank you for finding that out - that's extremely helpful.

Do you have any documentation on the wildcard syntax? I've tried "*word*" (without the quotes) but this still returns nothing.

Regards

Greg_Kujawa
Shopify Partner
1020 83 262

@Andrew_Smith5 , that's strange that the wildcard query isn't working. At least my GraphiQL test calls with the 2021-01 API version worked fine like this below. Any product that has chain in the title came back in the response. Although any product that just had chain and nothing else in the title wasn't included. Overall I think this area is a bit shaky in terms of searching titles...lol.

 

{
  products(first: 10, query: "title:*chain*") {
    edges {
      node {
        id
        title
      }
    }
  }
}
_JB
Shopify Staff
Shopify Staff
835 99 207

Hey @Andrew_Smith5,

The docs for search syntax are here: https://shopify.dev/concepts/about-apis/search-syntax

If you're still having trouble with it, please provide the X-Request-ID value from the response headers of your call, and I'll use that to find more info in our logs.

JB | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog