我无法为当前的数据集/映射创建ElasticSearch查询。我当前的映射:
"products": {
"mappings": {
"properties": {
"active": {
"type": "long"
},
"attributes": {
"properties": {
"created_at": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"id": {
"type": "long"
},
"language_code": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"product_column_id": {
"type": "long"
},
"product_id": {
"type": "long"
},
"value": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
},
}
"id": {
"type": "long"
},
"published": {
"type": "long"
}
},
我想查询我的数据集(产品),以便可以选择具有某些属性的所有产品。每个属性都需要匹配多个条件。示例:
获取所有属性至少为product_column_id = 2 AND value ='3'的产品。
我尝试了所有我能想到的东西:
'bool' => [
'must' => [
[
'match' => [
'attributes.product_column_id' => 2
]
],
[
'match' => [
'attributes.value' => '3'
]
],
]
]
我也尝试使用过滤器:
'bool' => [
'filter' => [
[
'match' => [
'attributes.product_column_id' => 2
]
],
[
'match' => [
'attributes.value' => '3'
]
],
]
]
但是我仍然会获得所有包含属性值为4的产品,而没有正确的product_column_id(它将在整个值字段中搜索术语“ 4”。因此不完全匹配。
我使用PHP / Laravel / Elasticquent格式化查询,但这没关系。
谁能告诉我如何格式化查询以匹配包含不仅与值而且与product_column_id(以及将来的语言代码)匹配的属性的产品?
谢谢!