zoukankan      html  css  js  c++  java
  • ElasticSearch中如何让query should等同于filter should

    bool query

    must

    The clause (query) must appear in matching documents.

    should

    The clause (query) should appear in the matching document. In a boolean query with no must clauses, one or more should clauses must match a document. The minimum number of should clauses to match can be set using the minimum_should_matchparameter.

    must_not

    The clause (query) must not appear in the matching documents.

    The bool query also supports disable_coord parameter (defaults to false). Basically the coord similarity computes a score factor based on the fraction of all query terms that a document contains. See Lucene BooleanQuery for >{
        "bool" : {
            "must" : {
                "term" : { "user" : "kimchy" }
            },
            "must_not" : {
                "range" : {
                    "age" : { "from" : 10, "to" : 20 }
                }
            },
            "should" : [
                {
                    "term" : { "tag" : "wow" }
                },
                {
                    "term" : { "tag" : "elasticsearch" }
                }
            ],
            "minimum_should_match" : 1,
            "boost" : 1.0
        }
    }

    本文出自:
    http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html


    minimum_should_match 使用效果:bool query 中的should条件会过滤,相当于bool filter中should;且只能紧跟bool query中的should后面使用,其它位置会报异常

  • 相关阅读:
    文件同步
    Renesas PPP Mode
    PYTHON 常用API ***
    Python DB
    Python VIL Realse
    C BIN加密
    Python VIL Service Bin
    Python 定期检查Build_setting的编译情况
    Python 字串处理
    IP分片(IP Fragment)
  • 原文地址:https://www.cnblogs.com/crystaltu/p/8953340.html
Copyright © 2011-2022 走看看