欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

ElasticSearch6.x学习笔记:JavaAPI进行全文查询

程序员文章站 2022-07-07 22:34:14
1、全文查询概述 The high-level full text queries are usually used for running full text queries on ful...

1、全文查询概述

The high-level full text queries are usually used for running full text queries on full text fields like the body of an email. They understand how the field being queried is analyzed and will apply each field’s analyzer (or search_analyzer) to the query string before executing.

2、match query

The standard query for performing full text queries, including fuzzy matching and phrase or proximity queries.

QueryBuilder query=QueryBuilders.matchQuery(
        "name",                                              
        "kimchy elasticsearch"); 

3、multi_match query

The multi-field version of the match query.

QueryBuilder query=QueryBuilders.multiMatchQuery(
        "kimchy elasticsearch",                              
        "user", "message");

4、common_terms query

A more specialized query which gives more preference to uncommon words.

QueryBuilder query=QueryBuilders.commonTermsQuery("name", "kimchy");  

5、query_string query

Supports the compact Lucene query string syntax, allowing you to specify AND|OR|NOT conditions and multi-field search within a single query string. For expert users only.

QueryBuilder query=QueryBuilders.queryStringQuery("+kimchy -elasticsearch");

6、simple_query_string

A simpler, more robust version of the query_string syntax suitable for exposing directly to users.

QueryBuilder query=QueryBuilders.simpleQueryStringQuery("+kimchy -elasticsearch");