In App Search API how to check if the field exists or not in a document during search

In App Search API, how i can in query for documents that does not contain a particular field. In Elasticsearch we have "exists" keyword in while in App Search API there does not seems to be "exists" keyword to check if a field exists in a particular document.

Hey @jayrraval, you are correct, I don't believe there is an "exists" query for App Search.

Just thinking out loud, you could probably handle this with some pre-processing. Make sure that documents that don't have the field set get indexed with a consistent empty value, like: field: "".

Then in a query you could do:

  "filters" : {
    "field": ""
  }

Thanks Jason for the clarification. It seems in App Search API empty fields filters are not working. We might need to initialize the field with a constant (non-empty) value and filter on that constant value.

Ah, you're right. I suspect that is a bug, I can't imagine that is an intended behavior. I'll see if we can get that fixed. In the meantime, I recommend using a constant (non-empty) value as you suggested, or even a separate field, like isFieldSet: false.

Thanks Jason ! Appreciate your help !

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.