Since my index cannot be re-indexed easily, I had to go with Erick's first suggestion. I thought others might be interested in an example of the code (I did this using Lucene 2.4.1):
// This code worked best to deletes documents with a null field value... BooleanQuery nullFieldsOnlyQuery = new BooleanQuery(); MatchAllDocsQuery matchAllDocsQuery = new MatchAllDocsQuery(); // ConstantScoreRangeQuery does not throw a BooleanQuery.TooManyClauses exception. // A regular RangeQuery does throws a BooleanQuery.TooManyClauses exception. // Obviously the range may be different depending on the nature of the field involved. ConstantScoreRangeQuery nonNullFieldsRangeQuery = new ConstantScoreRangeQuery( theFieldName, "0", //zero "z", true, true); // Load up the BooleanQuery nullFieldsOnlyQuery.add( new MatchAllDocsQuery(), BooleanClause.Occur.MUST ); nullFieldsOnlyQuery.add( nonNullFieldsRangeQuery, BooleanClause.Occur.MUST_NOT ); // Delete the documents from the archive index indexWriter.deleteDocuments( nullFieldsOnlyQuery ); // End of code that worked best to delete documents with a null field value. // The following code did NOT always work to delete documents with a null field value. // I did get the code below to delete documents with a null field value in my Windows XP // environment when I simply added a document with "" for the field value. However, it did // not work in my CentOS environment. I imagine this failure had more to do with the way // those documents with a null field value ended up erroneously being indexed in CentOS // rather than with the difference in the OS itself. Term[] fieldTerms = new Term[ 1 ]; fieldTerms[0] = new Term( theFieldName, "" ); indexWriter.deleteDocuments( fieldTerms ); // End of code that did NOT always work for me. Frank Geary -- View this message in context: http://lucene.472066.n3.nabble.com/Searching-for-null-empty-fields-how-to-use-field-TO-tp552476p1603932.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