That is the "Solr" answer. But it is slow like hell. In Lucene there is a natove query named FieldValueQuery already for this. It requires DocValues enabled for the field.
IMHO, the best and fastest variant (also to Solr users) is to add a separate multivalued string field named 'fieldnames' where you index all field named that have a value. After that you can query on this using the field name. Elasticsearch is doing the field name approach for exists/not exists by default. Uwe Am 15. Juli 2017 11:56:16 MESZ schrieb Ahmet Arslan <iori...@yahoo.com.INVALID>: >Hi, >Yes, here it is: q=+*:* -field3:[* TO *] >Ahmet >On Saturday, July 15, 2017, 8:16:00 AM GMT+3, Rajnish kamboj ><rajnishk7.i...@gmail.com> wrote: > > >Hi >Does Lucene provide any API to fetch documents for which a field is not >defined. > >Example >Document1 : field1=value1, field2=value2,field3=value3 > >Document2 : field1=value4, field2=value4 > >I want a query to get documents for which field3 is not defined. In >example >it should return Document2. > >Regards >Rajnish -- Uwe Schindler Achterdiek 19, 28357 Bremen https://www.thetaphi.de