尝试使用“terms_set”查询时,我完全搞不懂。
首先,in the docs,它说minimum_should_match_field
是一个可选字段。但我得到这个failed to create query: No minimum should match has been specified
错误,如果我不包括在请求中。如下:
POST bw-ecom-1/_search
{
"query": {
"terms_set": {
"category": {
"terms": [
"Men's wear", "Women's wear", "Unisex"
]
}
}
}
}
然后,当我包含minimum_should_match_field
时,我得到了另一个错误failed to find minimum_should_match field
。我也尝试过传递几个值。例如required_matches
,1
,2
,3
,...
这是我索引的文档:
{
"id": 1,
"name": "white t-shirt for men",
"short_description": "",
"category": [
"Men's wear",
"Women's wear",
"Unisex"
],
"min_price": 10000,
"max_price": 15000,
"discount": "0.05",
"currency": "VND",
"created": "2022-03-13",
"modifided": "1678700615438",
"indexed_at": "2022-03-13",
"variants": [
{
"color": ["red"],
"size": ["XL", "L"],
"form": "short sleeve",
"price": 12000,
"variant_id": "v-001",
"label": "red short sleeve men t-shirt"
}
],
"inventory": [
{
"variant_id": "v-001",
"storage_qty": 100
}
]
}
谢谢你帮我!
2条答案
按热度按时间8yparm6h1#
我不知道您使用terms_set查询的原因,但是
required_matches
应该在文档中。例如:
或
是的,
minimum_should_match_field
和minimum_should_match_script
是可选的。但是您需要至少使用其中的一个:)gv8xihay2#
抱歉,我忘了说为什么要使用
terms_set
,因为我想搜索包含所有术语的文档,在这种情况下,您应该这样做: