• es 全文查询


    搜索匹配所有matchAllQuery、全文查询[matchQuery、multiMatchQuery、commonTerms...

    • 匹配所有

    最简单的查询,匹配所有文档,给它们一个_score 1.0。

    QueryBuilder qb = matchAllQuery();
    • 匹配查询:用于执行全文查询的标准查询,包括模糊匹配和短语或邻近查询。//查询出包含 value 的数据 或者包含不连续的字符
    QueryBuilder qb = matchQuery("field","value" );
    
    示例:查询:QueryBuilder qb = matchQuery("name", "张三");
    
    结果
    
    数据:{"address":"benjing","age":"12","name":"张三2"}
    数据:{"address":"benjing","age":"12","name":"aa张三3","num":12}
    数据:{"address":"benjing","age":"12","name":"张爱三","num":12}
    数据:{"address":"benjing","age":"12","name":"张三3"}
    数据:{"address":"benjing","age":"12","name":"李宏旭 张三3","num":12}
    数据:{"address":"benjing","age":"12","name":"张四","num":12}
    • 多匹配查询:multi_match查询,匹配查询的多字段版
    QueryBuilder qb = multiMatchQuery(
        "kimchy elasticsearch",  //"user", "message"         //字段
    );

    示例:查询:QueryBuilder qb = multiMatchQuery("张三 12", "name","age");

    结果

    数据:{"address":"benjing","age":"1","name":"张三"}
    数据:{"address":"benjing","age":"12","name":"张三2"}
    数据:{"address":"benjing","age":"12","name":"aa张三3","num":12}
    数据:{"address":"benjing","age":"12","name":"张爱三","num":12}
    数据:{"address":"benjing","age":"12","name":"张三3"}
    数据:{"address":"benjing","age":"12","name":"李宏旭 张三3","num":12}
    数据:{"address":"benjing","age":"12","name":"王五","num":3}
    数据:{"address":"benjing","age":"12","name":"张四","num":12}
    数据:{"address":"benjing","age":"12","name":"王五"}
    • common_terms查询:一个更专业的查询,它提供了对不常见单词的更多偏好

    QueryBuilder qb = commonTermsQuery("field","value");

    示例:查询:QueryBuilder qb = commonTermsQuery("name", "张三");

    结果:

    数据:{"address":"benjing","age":"1","name":"张三"}
    数据:{"address":"benjing","age":"12","name":"张三2"}
    数据:{"address":"benjing","age":"12","name":"aa张三3","num":12}
    数据:{"address":"benjing","age":"12","name":"张爱三","num":12}
    数据:{"address":"benjing","age":"12","name":"张三3"}
    数据:{"address":"benjing","age":"12","name":"李宏旭 张三3","num":12}
    • query_string查询:支持紧凑的Lucene查询字符串语法,允许您在单个查询字符串中指定AND | OR | NOT条件和多字段搜索。仅限专家用户

    QueryBuilder qb = queryStringQuery("+kimchy -elasticsearch"); //value
    • simple_query_string:query_string语法的更简单,更健壮的版本,适合直接向用户公开

    QueryBuilder qb = simpleQueryStringQuery("+kimchy -elasticsearch");//value
    故乡明
  • 相关阅读:
    pgloader-pg迁移神器
    PostgreSQL备份工具-pg_probackup
    5、pgpool-II高可用性(一)数据库的高可用性
    4、pgpool-II 流复制模式
    3、pgpool-II 内置复制模式
    pgpool-II 的配置
    pgpool-II安装
    PG时间相减
    PostgreSQL 流复制解惑
    PostgreSQL改造非分区表为分区表
  • 原文地址:https://www.cnblogs.com/luweiweicode/p/14072203.html
Copyright © 2020-2023  润新知