use of org.apache.lucene.search.spans.FieldMaskingSpanQuery in project elasticsearch by elastic.
the class FieldMaskingSpanQueryBuilder method doToQuery.
@Override
protected SpanQuery doToQuery(QueryShardContext context) throws IOException {
String fieldInQuery = fieldName;
MappedFieldType fieldType = context.fieldMapper(fieldName);
if (fieldType != null) {
fieldInQuery = fieldType.name();
}
Query innerQuery = queryBuilder.toQuery(context);
assert innerQuery instanceof SpanQuery;
return new FieldMaskingSpanQuery((SpanQuery) innerQuery, fieldInQuery);
}
use of org.apache.lucene.search.spans.FieldMaskingSpanQuery in project elasticsearch by elastic.
the class FieldMaskingSpanQueryBuilderTests method doAssertLuceneQuery.
@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())));
}
Aggregations