0

I'm trying to do create a query to exclude all documents which have an empty/null value in one specific field.

What is the query syntax or the programmatic way to do this?

nanoman
  • 1,069
  • 12
  • 27

1 Answers1

1

You can use a required range query, which is open at both sides, like:

+field:[* TO *]

That is probably adequate, assuming that the documents to exclude have no value in the index.

If some form of default value appears, you would have to exclude that value as well, like:

+field:[* TO *] -field:NULL
femtoRgon
  • 32,893
  • 7
  • 60
  • 87
  • Thanks for the hint! However, with `+field:[* TO *]` I get a `ZendSearch\Lucene\Search\Exception\QueryParserException: At least one range query boundary term must be non-empty term`. Changing this to `+field:[0 TO *]` did the trick! – nanoman Jan 29 '13 at 08:02