Search in sources :

Example 1 with MatchPhraseQueryBuilder

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"));
}
Also used : MatchPhraseQueryBuilder(org.elasticsearch.index.query.MatchPhraseQueryBuilder) BytesArray(org.elasticsearch.common.bytes.BytesArray) SearchResponse(org.elasticsearch.action.search.SearchResponse) MultiSearchResponse(org.elasticsearch.action.search.MultiSearchResponse)

Example 2 with MatchPhraseQueryBuilder

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;
}
Also used : MatchPhraseQueryBuilder(org.elasticsearch.index.query.MatchPhraseQueryBuilder)

Example 3 with MatchPhraseQueryBuilder

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;
}
Also used : MatchPhraseQueryBuilder(org.elasticsearch.index.query.MatchPhraseQueryBuilder)

Example 4 with MatchPhraseQueryBuilder

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;
}
Also used : MatchPhraseQueryBuilder(org.elasticsearch.index.query.MatchPhraseQueryBuilder)

Aggregations

MatchPhraseQueryBuilder (org.elasticsearch.index.query.MatchPhraseQueryBuilder)4 MultiSearchResponse (org.elasticsearch.action.search.MultiSearchResponse)1 SearchResponse (org.elasticsearch.action.search.SearchResponse)1 BytesArray (org.elasticsearch.common.bytes.BytesArray)1