我相信是許多使用彈性搜索的用例。這裏是我的模板彈性搜索與英文分析器匹配的確切字符串
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