我添加了一个同义词分析器并过滤到我的弹性索引,以便在按状态搜索时,"马萨诸塞州," "马"和#34;弥撒,"例如,将返回相同的结果。这些是我的设置:
analysis":{
"analyzer":{
"synonyms":{
"filter":[
"lowercase",
"synonym_filter"
],
"tokenizer": "standard"
},
"my_analyzer":{
"filter":["standard", "lowercase", "my_soundex" ],
"tokenizer": "standard"}
},
"filter":{
"my_soundex":{
"replace": "false",
"type": "phonetic",
"encoder": "soundex"
},
"synonym_filter":{
"type": "synonym",
"synonyms":[
"United States,US,USA,USA=>usa",
"Alabama,Al,Ala,Ala",
"Alaska,Ak,Alas,Alas",
"Arizona,Az,Ariz",
"Arkansas,Ar,Ark",
"California,Ca,Calif,Cal",
"Colorado,Co,Colo,Col",
"Connecticut,Ct,Conn",
"Deleware,De,Del",
"District of Columbia,Dc,Wash Dc,Washington Dc=>Dc",
"Florida,Fl,Fla,Flor",
"Georgia,Ga",
"Hawaii,Hi",
"Idaho,Id,Ida",
"Illinois,Il,Ill,Ills",
"Indiana,In,Ind",
"Iowa,Ia,Ioa",
"Kansas,Kans,Kan,Ks",
"Kentucky,Ky,Ken,Kent",
"Louisiana,La",
"Maine,Me",
"Maryland,Md",
"Massachusetts,Ma,Mass",
"Michigan,Mi,Mich",
"Minnesota,Mn,Minn",
"Mississippi,Ms,Miss",
"Missouri,Mo",
"Montana,Mt,Mont",
"Nebraska,Ne,Neb,Nebr",
"Nevada,Nv,Nev"
"New Hampshire,Nh=>Nh",
"New Jersey,Nj=>Nj",
"New Mexico,Nm,N Mex,New M=>Nm",
"New York,Ny=>Ny",
"North Carolina,Nc,N Car=>Nc",
"North Dakota,Nd,N Dak, NoDak=>Nd",
"Ohio,Oh,O",
"Oklahoma,Ok,Okla",
"Oregon,Or,Oreg,Ore",
"Pennsylvania,Pa,Penn,Penna",
"Rhode Island,Ri,Ri & PP,R Isl=>Ri",
"South Carolina,Sc,S Car=>Sc",
"South Dakota,Sd,S Dak,SoDak=>Sd",
"Tennessee,Te,Tenn",
"Texas,Tx,Tex",
"Utah,Ut",
"Vermont,Vt",
"Virginia,Va,Virg",
"Washington,Wa,Wash,Wn",
"West Virginia,Wv,W Va, W Virg=>Wv",
"Wisconsin,Wi,Wis,Wisc",
"Wyomin,Wi,Wyo"
]
}
}
}
但是,同义词过滤器似乎并不起作用。以下是我尝试的两个查询:
"match": {
"location.location_raw": {
"type": "boolean",
"operator": "AND",
"query": "Massachusetts",
"analyzer": "synonyms"
}
}
"match": {
"location.location_raw": {
"type": "boolean",
"operator": "AND",
"query": "Mass",
"analyzer": "synonyms"
}
}
使用同义词过滤器,我应该为两个查询获得相同数量的结果,但我得到6个结果#34;马萨诸塞州" " Mass,"当我查看结果时,第一个查询的所有location_raw字段都包含" Massachusetts"而第二个查询的所有location_raw字段都包含" Mass"究竟。似乎同义词anazlyer似乎被忽略了。
我在这里缺少什么?