robodasha
robodasha

Reputation: 286

Lucene -- filter documents with specific field

With regard to my previous question (Lucene downgrade 3.6.0 to 3.5.0) I was wondering how could I filter out those documents (in Lucene 3.5.0) that have or don't have specific field (regardless the contents of the field). In Lucene 3.6.0 there is a FieldValueFilter class that can be used to do this. Same question was asked here but I'm not sure how could I accomplish the same thing using the API.

Upvotes: 1

Views: 1342

Answers (1)

robodasha
robodasha

Reputation: 286

In the end I found the solution myself. I used TermRangeFilter. The field I was working with contained IDs (stored as strings), so I used the following filter:

Filter filter = new TermRangeFilter("field", "0", null, true, false);

The same thing can be achieved also with this shorted code:

Filter filter = TermRangeFilter.More("filter", "0");

This solution seems to work. I hope this will help someone!

Upvotes: 1

Related Questions