這是我的代碼爲什麼同義詞本例中沒有工作
curl -XPUT "http://localhost:9200/my_index" -d '
{
"settings" : {
"analysis" : {
"filter" : {
"my_synonym_filter" : {
"type" : "synonym",
"synonyms" : [
"luck,love"
]
}
},
"analyzer" : {
" my_synonym_filter " : {
"tokenizer" : "standard",
"filter" : [
"lowercase",
"my_synonym_filter"
]
}}}}}'
curl -XPUT "http://localhost:9200/my_index/_mapping/doc?pretty" -d '
{
"properties" : {
"description" : {
"type" : "string",
"fields" : {
"ss" : {
"type" : "string",
"analyzer" : " my_synonym_filter "
}}}}}'
curl -XPUT "http://localhost:9200/my_index/doc/1" -d '
{
"description" : "luck is the best in the world"
}
'
curl -XPUT "http://localhost:9200/my_index/doc/2" -d '
{
"description" : "luck is just wonderful"
}
'
,你看,我創建了兩個同義詞詞luck
和love
使用自定義分析
但是當我做這個查詢
curl -XGET "http://localhost:9200/my_index/_search?pretty" -d '
{
"query" : {
"match" : {
"description" : "love"
}
}
}
'
我沒有結果,雖然愛情是運氣的同義詞
爲什麼要這樣?我的代碼有什麼問題?
你解決到底問題了嗎? – CrnaStena
@CrnaStena是的比你,你的解決方案工作 –
好極了。你介意加註和/或將其標記爲答案? – CrnaStena