Java 类org.apache.lucene.search.spans.FieldMaskingSpanQuery 实例源码

项目:elasticsearch_my    文件:FieldMaskingSpanQueryBuilderTests.java   
@Override
protected void doAssertLuceneQuery(FieldMaskingSpanQueryBuilder queryBuilder, Query query, SearchContext context) throws IOException {
    String fieldInQuery = queryBuilder.fieldName();
    MappedFieldType fieldType = context.getQueryShardContext().fieldMapper(fieldInQuery);
    if (fieldType != null) {
        fieldInQuery = fieldType.name();
    }
    assertThat(query, instanceOf(FieldMaskingSpanQuery.class));
    FieldMaskingSpanQuery fieldMaskingSpanQuery = (FieldMaskingSpanQuery) query;
    assertThat(fieldMaskingSpanQuery.getField(), equalTo(fieldInQuery));
    assertThat(fieldMaskingSpanQuery.getMaskedQuery(), equalTo(queryBuilder.innerQuery().toQuery(context.getQueryShardContext())));
}
项目:lucenelab    文件:SimplePreAnnotatedTokenFilterExample.java   
private static void searchForColoredFox(IndexSearcher searcher) throws IOException {
    final SpanQuery anyColor = new SpanTermQuery(new Term(COLOR_FIELD, ANY_ANNOTATION_TERM));
    final SpanQuery colorAsText = new FieldMaskingSpanQuery(anyColor, TEXT_FIELD);
    final SpanQuery fox = new SpanTermQuery(new Term(TEXT_FIELD, "fox"));
    final SpanQuery coloredFox = new SpanNearQuery(new SpanQuery[] { colorAsText, fox }, 0, true);
    search(searcher, coloredFox);
}
项目:lucenelab    文件:AnnotatorAnyExample.java   
private static void searchForRedAnimal(IndexSearcher searcher) throws IOException {
    final SpanQuery red = new SpanTermQuery(new Term(COLOR_FIELD, "red"));
    final SpanQuery redColorAsAnimal = new FieldMaskingSpanQuery(red, ANIMAL_FIELD);
    final SpanQuery anyAnimal = new SpanTermQuery(new Term(ANIMAL_FIELD, AnyAnnotationTokenFilter.ANY_ANNOTATION_TERM));
    final SpanQuery redAnimals = new SpanNearQuery(new SpanQuery[] { redColorAsAnimal, anyAnimal }, 0, true);
    search(searcher, redAnimals);
}
项目:lucenelab    文件:PreAnnotatedTokenFilterExample.java   
private static void searchForColoredFox(IndexSearcher searcher) throws IOException {
    final SpanQuery anyColor = new MultiPositionSpanTermQuery(new Term(COLOR_FIELD, ANY_ANNOTATION_TERM));
    final SpanQuery colorAsText = new FieldMaskingSpanQuery(anyColor, TEXT_FIELD);
    final SpanQuery fox = new SpanTermQuery(new Term(TEXT_FIELD, "fox"));
    final SpanQuery coloredFox = new SpanNearQuery(new SpanQuery[] { colorAsText, fox }, 0, true);
    search(searcher, coloredFox);
}
项目:lucenelab    文件:AnnotatorTeeSinkFilterExample.java   
private static void searchForBrownFox(IndexSearcher searcher) throws IOException {
    final SpanQuery brown = new SpanTermQuery(new Term(COLOR_FIELD, "brown"));
    final SpanQuery brownText = new FieldMaskingSpanQuery(brown, TEXT_FIELD);
    final SpanQuery fox = new SpanTermQuery(new Term(TEXT_FIELD, "fox"));
    search(searcher, new SpanNearQuery(new SpanQuery[] { brownText, fox }, 1, true));
}
项目:lucenelab    文件:AnnotatorTokenFilterExample.java   
private static void searchForBrownFox(IndexSearcher searcher) throws IOException {
    final SpanQuery brown = new SpanTermQuery(new Term(COLOR_FIELD, "brown"));
    final SpanQuery brownText = new FieldMaskingSpanQuery(brown, TEXT_FIELD);
    final SpanQuery fox = new SpanTermQuery(new Term(TEXT_FIELD, "fox"));
    search(searcher, new SpanNearQuery(new SpanQuery[] { brownText, fox }, 0, true));
}