当前位置: 首页>>代码示例>>Java>>正文


Java QueryBuilders.multiMatchQuery方法代码示例

本文整理汇总了Java中org.elasticsearch.index.query.QueryBuilders.multiMatchQuery方法的典型用法代码示例。如果您正苦于以下问题:Java QueryBuilders.multiMatchQuery方法的具体用法?Java QueryBuilders.multiMatchQuery怎么用?Java QueryBuilders.multiMatchQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.index.query.QueryBuilders的用法示例。


在下文中一共展示了QueryBuilders.multiMatchQuery方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test

import org.elasticsearch.index.query.QueryBuilders; //导入方法依赖的package包/类
/**
 * Here to establish QueryBuilder patterns
 */
void test() {
	SearchSourceBuilder b;
	BoolQueryBuilder qb = QueryBuilders.boolQuery();
	QueryBuilder qbmm = QueryBuilders.multiMatchQuery("name", "fieldNames");
	QueryBuilder qbm = QueryBuilders.matchQuery("name", "text");
	QueryBuilder qbmp = QueryBuilders.matchPhraseQuery("name", "text");
	QueryBuilder qb1 = QueryBuilders.termQuery(ITQCoreOntology.TUPLE_SUBJECT_PROPERTY, "");
	QueryBuilder qb2 = QueryBuilders.termQuery(ITQCoreOntology.TUPLE_OBJECT_PROPERTY, "");
	QueryBuilder qb3 = QueryBuilders.termQuery(ITQCoreOntology.INSTANCE_OF_PROPERTY_TYPE, "");
	qb.must(qb3);
	qb.should(qb1);
	qb.should(qb2);
	QueryBuilder partial = QueryBuilders.regexpQuery("name", "regexp");
	QueryBuilder wildcard = QueryBuilders.wildcardQuery("name", "query");
}
 
开发者ID:topicquests,项目名称:backside-servlet-ks,代码行数:19,代码来源:ElasticQueryDSL.java

示例2: testForClient

import org.elasticsearch.index.query.QueryBuilders; //导入方法依赖的package包/类
@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();

}
 
开发者ID:felayman,项目名称:elasticsearch-full,代码行数:32,代码来源:MultiMatchQueryDemo.java

示例3: goodSearch

import org.elasticsearch.index.query.QueryBuilders; //导入方法依赖的package包/类
/**
 * http://blog.csdn.net/xiaohulunb/article/details/37877435
 */
public static <Goods> Pagination<Goods> goodSearch(GoodsSearchCondition condition, String sortField, boolean desc, int from, int size) {
    String value = condition.getGoodsName();
    if (Pinyin4jUtil.isContainChinese(condition.getGoodsName())) {
        MultiMatchQueryBuilder multiMatchQueryBuilder = QueryBuilders.multiMatchQuery(value,
                "categoryName1", "categoryName2", "categoryName3", "goodsName", "goodsSkuAttr");
        multiMatchQueryBuilder.field("categoryName1", 0.8f);
        multiMatchQueryBuilder.field("categoryName2", 1f);
        multiMatchQueryBuilder.field("categoryName3", 1.5f);
        multiMatchQueryBuilder.field("goodsName", 2f);
        multiMatchQueryBuilder.field("goodsSkuAttr", 0.8f);
        Pagination<Goods> goodsPagination =
                search(multiMatchQueryBuilder, IndexType.GOODS, sortField, desc, from, size);
        if (!CollectionUtils.isEmpty(goodsPagination.getDataList())) {
            return goodsPagination;
        }
    }
    return boolSearch(sortField, desc, from, size, StringUtils.lowerCase(value));

}
 
开发者ID:wxz1211,项目名称:dooo,代码行数:23,代码来源:IndexManager.java


注:本文中的org.elasticsearch.index.query.QueryBuilders.multiMatchQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。