"Invalid search field for this query" for example query on Customer-Resource

Hello,

i am running the example for the customers query from the docs and can’t seem to get the search query to work.

This is the query im running at the moment:

query {
  customers(first: 1, query: "country:canada") {
    edges {
      node {
        id
        displayName
        firstName
        lastName
      }
    }
  }
}

The query returns a customer as a result (which it shouldnt, because there are no canadian customers) and the following error regarding the search query.

"search": [{
        "path": [
            "customers"
        ],
        "query": "country:canada",
        "parsed": {
            "field": "country",
            "match_all": "canada"
        },
        "warnings": [{
                "field": "country",
                "message": "Invalid search field for this query."
            }
        ]
    }
]

The same thing happens with a bunch of different search query i’d expect to work.

 "search": [
        {
          "path": [
            "customers"
          ],
          "query": "created_at:>'2020-10-21T23:39:20Z'",
          "parsed": {
            "field": "created_at",
            "range_gt": "2020-10-21T23:39:20Z"
          },
          "warnings": [
            {
              "field": "created_at",
              "message": "Invalid search field for this query."
            }
          ]
        }
      ]

I’m a bit puzzled by the Invalid serach field for this query-error and can’t get any search query to work. Can someone please tell me what i’m doing wrong?

And another general question: Where do i find an list of the available search fields for a given resource? I found some fields through the search-syntax doc, but no exhaustive list. Especially for the resource-specific search fields, which presumably exist.

I checked the Shopify API doc and it seems that neither GraphQL nor REST currently support querying based on country

Hey folks,

Seeing the same myself, this could be a documentation error - connecting with the relevant team to confirm.

So the documentation is wrong in regards to mentioning the country in the example code? What about the created_at-field?

I tried @kyle_liu suggested search query from Get all customers with a specific tag in Admin API - #7 by kyle_liu, which does no longer throw a parsing error for the query but also does not return any customer which is not the expected result.

query {
  customers(first: 1, query: "customer_tags CONTAINS 'ABC'") {
    edges {
      node {
        id
        displayName
        firstName
      }
    }
  }
}

I have a customer with a tag “ABC”, but the list returned is empty. Using the debug-parameter i get the following info about the search parsing.

"search": [{
        "path": [
            "customers"
        ],
        "query": "customer_tags CONTAINS 'ABC'",
        "parsed": {
            "and": [{
                    "field": "default",
                    "match_all": "customer_tags CONTAINS"
                }, {
                    "field": "default",
                    "match_phrase": "ABC"
                }
            ]
        }
    }
]

To me this looks like it did not understand the query as expected and is searching the “default”-fields (What are the default fields???) for "customer_tags CONTAINS" and "ABC".

I guess this circles back to my secondary question regarding a list of possible fields to use in the search querys. How does one know which fields are available and which are not?

Hi again,

I’ve confirmed with the team that owns this area that these are the filters you can use:


The customer filter was removed last year (see this changelog update) and we’ll update the code example in the docs to reflect that.

Okay, that clears it up. Maybe it would be a good idea to mention the customerSegmentMembers-query somewhere on the customer-query for people looking for extensive filtering.

One more question which is still unclear to me. What exactly are the default fields for an document?

Does this search through all the fields available on the customer-resource returned by the customer-query?

Thanks!