elasticsearch - 数组中的术语过滤器只考虑最后一项?

标签 elasticsearch

我想使用以下查询在 Elasticsearch 中搜索具有标签 a 或 b 或 c 的文档。但它总是返回只有 c 而忽略 a 或 b 的文档。任何人都可以帮助它吗?

"filtered": {
            "filter": {
                "term": {
                    "tags": ['a','b','c']
                }
            },
            "query": {
                match: {
                    rawText: 'filter'
                }

            }
        }

最佳答案

在 Elasticsearch 中,术语和术语过滤器之间存在差异。

术语过滤器:

{
    "constant_score" : {
        "filter" : {
            "term" : { "user" : "kimchy"}
        }
    }
}

术语过滤器:

{
    "constant_score" : {
        "filter" : {
            "terms" : {
                "user" : ["kimchy", "elasticsearch"],
                "execution" : "bool",
                "_cache": true
            }
        }
    }
}

尝试使用术语过滤器。

关于elasticsearch - 数组中的术语过滤器只考虑最后一项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31770247/

相关文章:

elasticsearch - 同一字段的 Elasticsearch 多个过滤器值

elasticsearch - Elasticsearch,对全文字符串进行过滤

elasticsearch - 在script_score中使用嵌套值

elasticsearch - 在ElasticSearch 5中将C#枚举另存为字符串而不是int

elasticsearch - Elasticsearch geo_shape过滤器无结果

ElasticSearch:按与日期的接近程度排名

curl - ElasticSearch错误-curl:(7)无法连接到localhost:9200;拒绝连接

elasticsearch - 如何减少Elasticsearch查询子句的数量?

elasticsearch - spring-data-elasticsearch-在同一字段上注释@Id时,@ Field映射类型将被忽略

elasticsearch - logstash不创建索引