gpt4 book ai didi

elasticsearch - elasticsearch匹配查询为嵌套字段返回空结果

转载 作者:行者123 更新时间:2023-12-03 00:48:20 32 4
gpt4 key购买 nike

我正在关注这个link
我有一个带有以下test_products的索引mapping:

{
"settings": {
"number_of_shards": 1
},
"mappings": {
"dynamic_templates": [
{
"search_result_data": {
"mapping": {
"type": "keyword"
},
"path_match": "search_result_data.*"
}
}
],
"properties": {
"search_data": {
"type": "nested",
"properties": {
"full_text": {
"type": "text"
},
"string_facet": {
"type": "nested",
"properties": {
"facet-name": {
"type": "keyword"
},
"facet-value": {
"type": "keyword"
}
}
}
}
}
}
}
}

并以以下格式插入文档:
    {
"search_result_data": {
"sku": "wheel-6075-90092",
"gtin": null,
"name": "Matte Black Wheel Fuel Ripper",
"preview_image": "abc.jg",
"url": "9836817354546538796",
"brand": "Fuel Off-Road"
},
"search_data":
{
"full_text": "Matte Black Wheel Fuel Ripper",
"string_facet": [
{
"facet-name": "category",
"facet-value": "Motor Vehicle Rims & Wheels"
},
{
"facet-name": "brand",
"facet-value": "Fuel Off-Road"
}
]
}
}

和其他一些文件

我正在尝试使用以下查询全文搜索索引:
{
"query": {
"match": {
"search_data.full_text": "Black"
}
}
}

尽管该字段包含术语 Black,但该查询的结果仍为空。

最佳答案

由于您的search_data字段是nested,因此您还需要使用 nested query:

{
"query": {
"nested": {
"path": "search_data",
"query": {
"match": {
"search_data.full_text": "Black"
}
}
}
}
}

关于elasticsearch - elasticsearch匹配查询为嵌套字段返回空结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57493805/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com