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.
Asked
Active
Viewed 1,315 times
1 Answers
1
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!

robodasha
- 286
- 6
- 21
-
If you want all values, then why limit by "0"? you could use: Filter filter = new TermRangeFilter("field", null, null, false, false); Which translates into: field:{* TO *} – Gili Nachum Jan 19 '13 at 20:00