use of org.apache.lucene.queries.intervals.IntervalsSource in project OpenSearch by opensearch-project.
the class IntervalBuilderTests method testOrdered.
public void testOrdered() throws IOException {
CannedTokenStream ts = new CannedTokenStream(new Token("term1", 1, 2), new Token("term2", 3, 4), new Token("term3", 5, 6));
IntervalsSource source = BUILDER.analyzeText(new CachingTokenFilter(ts), -1, true);
IntervalsSource expected = Intervals.ordered(Intervals.term("term1"), Intervals.term("term2"), Intervals.term("term3"));
assertEquals(expected, source);
}
use of org.apache.lucene.queries.intervals.IntervalsSource in project OpenSearch by opensearch-project.
the class IntervalBuilderTests method testGraphSynonymsWithGaps.
public void testGraphSynonymsWithGaps() throws IOException {
// term1 [] term2:4/term3 [] [] term4 term5
CannedTokenStream ts = new CannedTokenStream(new Token("term1", 1, 2), new Token("term2", 2, 3, 4, 4), new Token("term3", 0, 3, 4), new Token("term4", 3, 5, 6), new Token("term5", 6, 7));
IntervalsSource source = BUILDER.analyzeText(new CachingTokenFilter(ts), -1, true);
IntervalsSource expected = Intervals.ordered(Intervals.term("term1"), Intervals.or(Intervals.extend(Intervals.term("term2"), 1, 0), Intervals.phrase(Intervals.extend(Intervals.term("term3"), 1, 0), Intervals.extend(Intervals.term("term4"), 2, 0))), Intervals.term("term5"));
assertEquals(expected, source);
}
use of org.apache.lucene.queries.intervals.IntervalsSource in project OpenSearch by opensearch-project.
the class IntervalBuilderTests method testSimpleSynonymsWithGap.
public void testSimpleSynonymsWithGap() throws IOException {
// term1 [] term2/term3/term4 term5
CannedTokenStream ts = new CannedTokenStream(new Token("term1", 1, 2), new Token("term2", 2, 3, 4), new Token("term3", 0, 3, 4), new Token("term4", 0, 3, 4), new Token("term5", 5, 6));
IntervalsSource source = BUILDER.analyzeText(new CachingTokenFilter(ts), -1, true);
IntervalsSource expected = Intervals.ordered(Intervals.term("term1"), Intervals.extend(Intervals.or(Intervals.term("term2"), Intervals.term("term3"), Intervals.term("term4")), 1, 0), Intervals.term("term5"));
assertEquals(expected, source);
}
Aggregations