0
我是Elasticsearch的新手,現在我正在努力弄清爲什麼我的同義詞沒有像我期望的那樣返回任何結果。爲什麼我的同義詞什麼都不返回?
我爲我的同義詞文件創建了自定義過濾器和分析器,並將分析器應用於_all
字段並明確定義了specialty
字段以便使用它。
當我搜索"specialty": "aids"
沒有分析器/標記器,它給我如預期的零結果。
然而,當我搜索"specialty": "aids"
與分析儀/分詞,我希望它給我相同的結果搜索"speciality": "retrovirology"
,這應該產量3分的結果,但它什麼也沒有回來。
我是如何接近這個問題的嗎?
這裏是我的設置和一些樣本數據:
curl -XDELETE "http://localhost:9200/personsearch"
curl -XPUT "http://localhost:9200/personsearch" -d'
{
"settings": {
"index": {
"analysis": {
"analyzer": {
"XYZSynAnalyzer": {
"tokenizer": "standard",
"filter": [
"XYZSynFilter"
]
}
},
"filter": {
"XYZSynFilter": {
"type": "synonym",
"synonyms": [
"aids, retrovirology"
]
}
}
}
}
},
"mappings": {
"xyzemployee": {
"_all": {
"analyzer": "XYZSynAnalyzer"
},
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"middleName": {
"type": "string",
"include_in_all": false,
"index": "not_analyzed"
},
"specialty": {
"type": "string",
"analyzer": "XYZSynAnalyzer"
}
}
}
}
}'
curl -XPUT "http://localhost:9200/personsearch/xyzemployee/1" -d'
{
"firstName": "Don",
"middleName": "W.",
"lastName": "White",
"specialty": "Adult Retrovirology"
}'
curl -XPUT "http://localhost:9200/personsearch/xyzemployee/2" -d'
{
"firstName": "Terrance",
"middleName": "G.",
"lastName": "Gartner",
"specialty": "Retrovirology"
}'
curl -XPUT "http://localhost:9200/personsearch/xyzemployee/3" -d'
{
"firstName": "Carter",
"middleName": "L.",
"lastName": "Taylor",
"specialty": "Pediatric Retrovirology"
}'
# Why is this returning nothing?
curl -XGET "http://localhost:9200/personsearch/xyzemployee/_search?pretty=true" -d'
{
"query": {
"match": {
"specialty": "retrovirology"
}
}
}'
謝謝!順便說一下,過濾器是「小寫」,而不是「下」,因爲那些磕磕絆絆的人在這個問題上 – danyim
我應該先檢查一下。出於同樣的原因進行編輯。 :-) – GlenRSmith