use of org.elasticsearch.index.query.MatchPhraseQueryBuilder in project elasticsearch by elastic.
the class PercolatorQuerySearchIT method testTakePositionOffsetGapIntoAccount.
public void testTakePositionOffsetGapIntoAccount() throws Exception {
createIndex("test", client().admin().indices().prepareCreate("test").addMapping("type", "field", "type=text,position_increment_gap=5").addMapping("queries", "query", "type=percolator"));
client().prepareIndex("test", "queries", "1").setSource(jsonBuilder().startObject().field("query", new MatchPhraseQueryBuilder("field", "brown fox").slop(4)).endObject()).get();
client().prepareIndex("test", "queries", "2").setSource(jsonBuilder().startObject().field("query", new MatchPhraseQueryBuilder("field", "brown fox").slop(5)).endObject()).get();
client().admin().indices().prepareRefresh().get();
SearchResponse response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", "type", new BytesArray("{\"field\" : [\"brown\", \"fox\"]}"), XContentType.JSON)).get();
assertHitCount(response, 1);
assertThat(response.getHits().getAt(0).getId(), equalTo("2"));
}
use of org.elasticsearch.index.query.MatchPhraseQueryBuilder in project fess by codelibs.
the class EsAbstractConditionQuery method regMatchPhraseQ.
protected MatchPhraseQueryBuilder regMatchPhraseQ(String name, Object value) {
checkEsInvalidQuery(name, value);
MatchPhraseQueryBuilder matchQuery = QueryBuilders.matchPhraseQuery(name, value);
regQ(matchQuery);
return matchQuery;
}
use of org.elasticsearch.index.query.MatchPhraseQueryBuilder in project fess by codelibs.
the class EsAbstractConditionQuery method regMatchPhraseQ.
protected MatchPhraseQueryBuilder regMatchPhraseQ(String name, Object value) {
checkEsInvalidQuery(name, value);
MatchPhraseQueryBuilder matchQuery = QueryBuilders.matchPhraseQuery(name, value);
regQ(matchQuery);
return matchQuery;
}
use of org.elasticsearch.index.query.MatchPhraseQueryBuilder in project fess by codelibs.
the class EsAbstractConditionQuery method regMatchPhraseQ.
protected MatchPhraseQueryBuilder regMatchPhraseQ(String name, Object value) {
checkEsInvalidQuery(name, value);
MatchPhraseQueryBuilder matchQuery = QueryBuilders.matchPhraseQuery(name, value);
regQ(matchQuery);
return matchQuery;
}
Aggregations