Search code examples
ibm-watsonwatsonwatson-discovery

Querying for documents that have missing / undefined fields in Watson Discovery Service


We have a set of JSON documents loaded into Watson Discovery Service. Some have a field (say X) for example X: MyXValue and some don't have that field at all. Can I write a query in WDS language that will return all documents in the collection that are missing the X field? Thanks, Eldad


Solution

  • No, you can't write that query. The query operators are documented at

    https://console.bluemix.net/docs/services/discovery/query-operators.html#query-operators

    You might think that you could use the "does not include" operator with a wildcard (X:!*), but that doesn't return any results.

    If possible you should add an attribute to your documents so that you can test an attribute that is present, rather than trying to detect the absence of an attribute.