【发布时间】:2014-08-08 15:38:25
【问题描述】:
我正在尝试使用 _analyze API 获取关键字标记的多词同义词。 API 返回单词同义词的预期结果,但不是多词同义词。这是我的设置和分析链:
curl -XPOST "http://localhost:9200/test" -d'
{
"settings": {
"index": {
"analysis": {
"filter": {
"my_syn_filt": {
"type": "synonym",
"synonyms": [
"foo bar, fooo bar",
"bazzz, baz"
]
}
},
"analyzer": {
"my_synonyms": {
"filter": [
"lowercase",
"my_syn_filt"
],
"tokenizer": "keyword"
}
}
}
}
}
}'
现在使用 _analyze API 进行测试:
curl 'localhost:9200/test/_analyze?analyzer=my_synonyms&text=baz'
调用返回了我所期望的结果(对于 'bazzz' 也返回了相同的结果):
{
"tokens": [
{
"position": 1,
"type": "SYNONYM",
"end_offset": 3,
"start_offset": 0,
"token": "bazzz"
},
{
"position": 1,
"type": "SYNONYM",
"end_offset": 3,
"start_offset": 0,
"token": "baz"
}
]
}
现在,当我尝试使用多词同义词文本进行相同调用时,API 仅返回一个“单词”类型的标记,没有同义词:
curl 'localhost:9200/test/_analyze?analyzer=my_synonyms&text=foo+bar'
(返回)
{
"tokens": [
{
"position": 1,
"type": "word",
"end_offset": 7,
"start_offset": 0,
"token": "foo bar"
}
]
}
为什么分析 API 不返回 SYNONYM 类型的“foo bar”和“fooo bar”标记?
【问题讨论】:
标签: elasticsearch synonym