我在OpenSearch中有一个表,其中每个字段的格式都是“文本”。
我的table就是这个样子
现在我在opensearch中运行的query(q1)看起来是这样的。我没有得到任何输出。但是当我运行query q2时,我得到了输出。
q1 = {"size":10,"query":{"bool":{"must":[{"multi_match":{"query":"cen","fields":["name","alias"],"fuzziness":"AUTO"}}],"filter":[{"match_phrase":{"category":"Specialty"}},{"match_phrase":{"prov_type":"A"}},{"match_phrase":{"prov_type":"C"}}]}}}
q2 = {"size":10,"query":{"bool":{"must":[{"multi_match":{"query":"cen","fields":["name","alias"],"fuzziness":"AUTO"}}],"filter":[{"match_phrase":{"category":"Specialty"}},{"match_phrase":{"prov_type":"A"}}]}}}
现在我想在prov_type上应用多重过滤。我已经尝试过在列表中使用prov_type的术语,比如['A','B']。
有人能回答这个问题吗?如何在opensearch/elasticsearch中对单列的值应用多个过滤器。每个字段的数据类型都是文本。已经尝试过了-How to filter with multiple fields and values in elasticsearch?
索引的Map
GET index/_mapping
{
"spec_proc_comb_exp" : {
"mappings" : {
"properties" : {
"alias" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"category" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"prov_type" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"specialty_code" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
如果你需要更多的信息,请告诉我
1条答案
按热度按时间enyaitl31#
您可以使用
should
查询来筛选具有OR
条件的数据。注:You can set minimum_should_match as a number or percentage.