use of org.opengrok.suggest.query.SuggesterRangeQuery in project OpenGrok by OpenGrok.
the class SuggesterSearcherTest method testRangeQueryUpper.
@Test
public void testRangeQueryUpper() {
SuggesterRangeQuery q = new SuggesterRangeQuery("test", new BytesRef("opengrok"), new BytesRef("t"), true, true, SuggesterRangeQuery.SuggestPosition.UPPER);
List<LookupResultItem> suggestions = searcher.suggest(null, "test", q, k -> 0);
List<String> tokens = suggestions.stream().map(LookupResultItem::getPhrase).collect(Collectors.toList());
assertThat(tokens, contains("test"));
}
use of org.opengrok.suggest.query.SuggesterRangeQuery in project OpenGrok by OpenGrok.
the class SuggesterSearcherTest method testRangeQueryLower.
@Test
public void testRangeQueryLower() {
SuggesterRangeQuery q = new SuggesterRangeQuery("test", new BytesRef("o"), new BytesRef("test"), true, true, SuggesterRangeQuery.SuggestPosition.LOWER);
List<LookupResultItem> suggestions = searcher.suggest(null, "test", q, k -> 0);
List<String> tokens = suggestions.stream().map(LookupResultItem::getPhrase).collect(Collectors.toList());
assertThat(tokens, contains("opengrok", "opengrok2"));
}
use of org.opengrok.suggest.query.SuggesterRangeQuery in project OpenGrok by OpenGrok.
the class SuggesterQueryParser method newRangeQuery.
@Override
protected Query newRangeQuery(final String field, final String lowerTerm, final String upperTerm, final boolean startInclusive, final boolean endInclusive) {
if (lowerTerm.contains(identifier)) {
String bareLowerTerm = lowerTerm.replace(identifier, "");
replaceIdentifier(field, lowerTerm);
SuggesterRangeQuery rangeQuery = new SuggesterRangeQuery(field, new BytesRef(bareLowerTerm), new BytesRef(upperTerm), startInclusive, endInclusive, SuggesterRangeQuery.SuggestPosition.LOWER);
this.suggesterQuery = rangeQuery;
return rangeQuery;
} else if (upperTerm.contains(identifier)) {
String bareUpperTerm = upperTerm.replace(identifier, "");
replaceIdentifier(field, upperTerm);
SuggesterRangeQuery rangeQuery = new SuggesterRangeQuery(field, new BytesRef(lowerTerm), new BytesRef(bareUpperTerm), startInclusive, endInclusive, SuggesterRangeQuery.SuggestPosition.UPPER);
this.suggesterQuery = rangeQuery;
return rangeQuery;
}
return super.newRangeQuery(field, lowerTerm, upperTerm, startInclusive, endInclusive);
}
Aggregations