TermQuery and TermRangeQuery
A TermQuery
is a very simple query that matches documents containing a specific term. The TermRangeQuery
is, as its name implies, a term range with a lower and upper boundary for matching.
How to do it..
Here are a couple of examples on TermQuery
and TermRangeQuery
:
query = new TermQuery(new Term("content", "humpty")); query = new TermRangeQuery("content", new BytesRef("a"), new BytesRef("c"), true, true);
The first line is a simple query that matches the term humpty
in the content field. The second line is a range query matching documents with the content that's sorted within a and c.