Java Code Examples for org.elasticsearch.index.query.MultiMatchQueryBuilder#analyzer()

The following examples show how to use org.elasticsearch.index.query.MultiMatchQueryBuilder#analyzer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiMatchQueryDemo.java    From elasticsearch-full with Apache License 2.0 5 votes vote down vote up
@Test
public void testForClient() throws Exception {

    /**
     * @see <a href='https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-multi-match-query.html'></a>
     * MultiMatchQuery依赖于match query ,也就是其核心是基于MatchQuery构建的
     *
     */

    MultiMatchQueryBuilder multiMatchQueryBuilder = QueryBuilders.multiMatchQuery("elasticsearch match query","title", "descrption");

    multiMatchQueryBuilder.analyzer("standard");
    multiMatchQueryBuilder.cutoffFrequency(0.001f);
    multiMatchQueryBuilder.field("title",20);
    multiMatchQueryBuilder.fuzziness(Fuzziness.TWO);
    multiMatchQueryBuilder.maxExpansions(100);
    multiMatchQueryBuilder.prefixLength(10);
    multiMatchQueryBuilder.tieBreaker(20);
    multiMatchQueryBuilder.type(MultiMatchQueryBuilder.Type.BEST_FIELDS);
    multiMatchQueryBuilder.boost(20);



   SearchResponse searchResponse =  client.prepareSearch()
            .setIndices("blogs")
            .setTypes("blog")
            .setQuery(multiMatchQueryBuilder)
            .execute()
            .actionGet();

}
 
Example 2
Source File: Paramer.java    From elasticsearch-sql with Apache License 2.0 5 votes vote down vote up
public static ToXContent fullParamer(MultiMatchQueryBuilder query, Paramer paramer) {
    if (paramer.analysis != null) {
        query.analyzer(paramer.analysis);
    }

    if (paramer.boost != null) {
        query.boost(paramer.boost);
    }

    if (paramer.slop != null) {
        query.slop(paramer.slop);
    }

    if (paramer.type != null) {
        query.type(paramer.type);
    }

    if (paramer.tieBreaker != null) {
        query.tieBreaker(paramer.tieBreaker);
    }

    if (paramer.operator != null) {
        query.operator(paramer.operator);
    }

    if (paramer.minimumShouldMatch != null) {
        query.minimumShouldMatch(paramer.minimumShouldMatch);
    }

    query.fields(paramer.fieldsBoosts);

    return query;
}