我相信是许多使用弹性搜索的用例。这里是我的模板弹性搜索与英文分析器匹配的确切字符串
PUT _template/test
{
"template" : "test*",
"settings" : {
"number_of_shards" : 5,
"number_of_replicas" : 1
},
"mappings" : {
"test": {
"properties": {
"name": {
"type": "string",
"index": "analyzed"
},
"description": {
"type": "string",
"index": "analyzed",
"analyzer":"english",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}
现在我打算把单条记录在索引
POST /test/test
{
"name":"test-1",
"description":"on the first day of christmas my true love gave to me a partridge in a pear tree"
}
现在想象一下,我有这些记录一百万。我想要做的是,如果我在描述字段上搜索on the
,我不想回来,因为这些是英语分析器应该处理的常见词汇。但是,如果我搜索确切的文字"on the"
,那么我希望返回的文档与确切的文字相匹配。
我对弹性社区的问题是如何允许这个以及查询应该是什么样子?我添加了描述的.raw字段,但不管我的查询字符串是什么,我都无法得到确切的文本来返回任何结果。
你要查询像GET /测试/测试/ _search'{ “查询”:{ “术语”:{ “description.raw”: “上的” } }}' – Richa
当我运行的确切查询我得到'{ “花”:1, “TIMED_OUT”:假的, “_shards”:{ “总”:5, “成功”:5, “失败”:0 }, “命中”:{ “总”:0, “MAX_SCORE”:空, “点击”:[] } }' –
这可能是因为你没有任何说明与确切的文本 – Richa