![](/img/trans.png)
[英]Elasticsearch - how to search exact string match with special charater (-) in the json document
[英]How to search exact text in nested document in elasticsearch
我有这样的索引,
"_index": "test",
"_type": "products",
"_id": "URpYIFBAQRiPPu1BFOZiQg",
"_score": null,
"_source": {
"currency": null,
"colors": [],
"api": 1,
"sku": 9999227900050002,
"category_path": [
{
"id": "cat00000",
"name": "B1"
},
{
"id": "abcat0400000",
"name": "Cameras & Camcorders"
},
{
"id": "abcat0401000",
"name": "Digital Cameras"
},
{
"id": "abcat0401005",
"name": "Digital SLR Cameras"
},
{
"id": "pcmcat180400050006",
"name": "DSLR Package Deals"
}
],
"price": 1034.99,
"status": 1,
"description": null,
}
而且我只想在category_path字段中搜索确切的文本[“ Camcorders”]。 我做了一些匹配查询,但是它搜索了所有以“ Camcorders”作为文本一部分的产品。 有人可以帮我解决这个问题吗?
谢谢
要在嵌套字段中搜索,请使用以下查询
{
"query": {
"term": {
"category_path.name": {
"value": "b1"
}
}
}
}
希望能帮助到你..!
您可以使用not_analyzed
分析器再添加一个嵌套字段raw_name
其not_analyzed
匹配。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.