Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
<img src="//i.stack.imgur.com/RUiNP.png" height="16" width="18" alt="" class="sponsor tag img">elasticsearch ElasticSearch:仅当满足多个条件时才启动_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Nosql - Fatal编程技术网 elasticsearch ElasticSearch:仅当满足多个条件时才启动,elasticsearch,nosql,elasticsearch,Nosql" /> elasticsearch ElasticSearch:仅当满足多个条件时才启动,elasticsearch,nosql,elasticsearch,Nosql" />

elasticsearch ElasticSearch:仅当满足多个条件时才启动

elasticsearch ElasticSearch:仅当满足多个条件时才启动,elasticsearch,nosql,elasticsearch,Nosql,我有以下ElasticSearch查询: query: { bool: { must: [ { match_all: {} } ], should: [ { term: { company: { value: 'company', boost: 2 } } } { terms: { 'departments.id': 'company' } } ]

我有以下ElasticSearch查询:

    query: {
      bool: {
        must: [
          { match_all: {} }
        ],
        should: [
          { term: { company: { value: 'company', boost: 2 } } }
          { terms: { 'departments.id': 'company' } }
        ]
      }
    },
    sort: [
      '_score',
      { price: { order: 'desc' } }
    ]
  }
如果公司术语查询匹配,我想提高效率,但如果且仅当术语查询都匹配(company和department.id),我想提高效率


如何实现这一点?

您可以编写自定义评分逻辑,检查。可以编写自定义脚本并计算指定分数。您应该看到
script\u score
部分