Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to query lucene for empty fields?

Tags:

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

like image 476
Jonathan Ilambo Avatar asked Aug 09 '12 14:08

Jonathan Ilambo


2 Answers

*:*  -MY_FIELD_NAME:[* TO *]  

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

like image 144
Mikos Avatar answered Oct 19 '22 16:10

Mikos


*:* -MY_FIELD_NAME:[* TO "zzzzzzzzzz"] 

You can add more "z" chars to ensure to include any value of the field.

like image 26
riofly Avatar answered Oct 19 '22 18:10

riofly