0

Is it possible to filter a document by the value provided only if the document has the field.

For context,

I have document types A,B,C that have the field.

I also have document types D and E that don't.

I could define a query such that the filter only applies to the first subset, but I might later add a new document type to the first set which will invalidate this filter.

user3056052
  • 1,387
  • 2
  • 13
  • 16

1 Answers1

0

You'll have to combine the query with an match against all documents, except those who have a value in the field:

myfield:foobar OR (*:* NOT myfield:*)

.. should do what you want. That being said, I'd probably wait to introduce these additional queries until I actually see that it's needed, as it will make each query more expensive without possibly being necessary in the future - but that's up to your judgement.

Community
  • 1
  • 1
MatsLindh
  • 49,529
  • 4
  • 53
  • 84