How to query lucene for empty fields?

Jonathan Ilambo picture Jonathan Ilambo · Aug 9, 2012 · Viewed 25.6k times · Source

I want in 2nd part of my query to have a list of result for while data not null. I find how do it in solr but not in lucene. Anyone have a idea Thanks

String :

( field_one:search AND field_two:3000) OR (field_three:search AND field_two:3000 AND NOT NULL field_one )

Query:

+field_one:search +field_two:3000 +field_three:search +field_two:3000 -field_one:null

Answer

Mikos picture Mikos · Aug 9, 2012
*:*  -MY_FIELD_NAME:[* TO *] 

The above should do it, note the * : * for Lucene.