Search in sources :

Example 1 with RegexQuery

use of org.apache.lucene.sandbox.queries.regex.RegexQuery in project Krill by KorAP.

the class TestRelationIndex method testRelationWithRegex.

@Test
public void testRelationWithRegex() throws IOException {
    ki.addDoc(createFieldDoc0());
    ki.addDoc(createFieldDoc3());
    ki.commit();
    SpanQuery sq;
    sq = new SpanRelationQuery(new SpanMultiTermQueryWrapper<RegexQuery>(new RegexQuery(new Term("base", ">:xip/.*"))), true, RelationDirection.RIGHT);
    kr = ki.search(sq, (short) 10);
    assertEquals((long) 7, kr.getTotalResults());
    sq = new SpanRelationQuery(new SpanMultiTermQueryWrapper<RegexQuery>(new RegexQuery(new Term("base", "<:xip/.*"))), true, RelationDirection.LEFT);
    kr = ki.search(sq, (short) 10);
    assertEquals((long) 7, kr.getTotalResults());
}
Also used : SpanMultiTermQueryWrapper(org.apache.lucene.search.spans.SpanMultiTermQueryWrapper) SpanRelationQuery(de.ids_mannheim.korap.query.SpanRelationQuery) RegexQuery(org.apache.lucene.sandbox.queries.regex.RegexQuery) Term(org.apache.lucene.index.Term) SpanQuery(org.apache.lucene.search.spans.SpanQuery) Test(org.junit.Test)

Aggregations

SpanRelationQuery (de.ids_mannheim.korap.query.SpanRelationQuery)1 Term (org.apache.lucene.index.Term)1 RegexQuery (org.apache.lucene.sandbox.queries.regex.RegexQuery)1 SpanMultiTermQueryWrapper (org.apache.lucene.search.spans.SpanMultiTermQueryWrapper)1 SpanQuery (org.apache.lucene.search.spans.SpanQuery)1 Test (org.junit.Test)1