There is a Filter that can find documents *without* or *with any* value: FieldValueFilter
http://lucene.apache.org/core/4_3_0/core/org/apache/lucene/search/FieldValueFilter.html You can create a query out of it: new ConstantScoreQuery(new FieldValueFilter("fieldname", true)) Uwe ----- Uwe Schindler H.-H.-Meier-Allee 63, D-28213 Bremen http://www.thetaphi.de eMail: u...@thetaphi.de > -----Original Message----- > From: srividhyau [mailto:srividhya.umashan...@hp.com] > Sent: Monday, May 13, 2013 8:05 PM > To: java-user@lucene.apache.org > Subject: Performance of NULL check *:* -category:[* TO *] > > All - > > We have a necessity to check for attributes with null values. > There are 2 options that we narrowed down to > > 1. Either we index null values with 'NULL' string and then check against the > string. > This has a drawback as Lucene does not have the capability of setting any > default value. and each document may have a different set of fields to index. > > 2. The other approach is to check the negative query as follows, which does > fetch me all the documents that has category with null > *:* -_category:[* TO *] > > > Question: > 1. Is there any impact in the query peformance (execution time) if you do the > above query because we fetch all documents and then negate. Has anybody > tried checking the Query performance 2. Assume we are talking of 10 million > documents in the index. > > -Vidhya > > > > > > > -- > View this message in context: > http://lucene.472066.n3.nabble.com/Performance-of-NULL-check-category- > TO-tp4063021.html > Sent from the Lucene - Java Users mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org