ElasticSearch:全文搜索变得容易 [英] ElasticSearch: Full-Text Search made easy
问题描述
我正在调查从 SphinxSearch
中切换到 ElasticSearch
的可能性。
有什么好的 SphinxSearch
- 全文搜索只是在相当不错的水平上工作的机器人。在 ElasticSearch
中显示出不像我预期的那样简单。
在我的项目中,我有一个带有头文字的搜索框,表示我打电话 Clint E
,首先查看包含 Clint Eastwood
的下拉列表。键入 robert down
,首先查看 Robert Downey Jr。
。所有这一切,我使用 SphinxSearch
刚刚提供了我的DB凭据和SQL查询来拉取必要的字段。
另一方面,使用 ElasticSearch
即使在阅读有关
一个字母后,弹性发现!
同时Sphinx闪耀:)
弹性游戏附带汽车完成建议。
您不需要将其放入查询功能,其工作方式是在令牌级别,而不是部分令牌级别。
去完成建议,它也支持模糊逻辑。
I am investigate possibility to switch to ElasticSearch
from SphinxSearch
.
What is good about SphinxSearch
- full-text search just work out of the bot on pretty good level. Make it work on ElasticSearch
appeared not as easy as I expected.
In my project I have search box with typeahead, means I stype Clint E
and see dropdown with results including Clint Eastwood
on the first place. Type robert down
and see Robert Downey Jr.
on the first place. All this I achieved with SphinxSearch
out of the box just providing it my DB credentials and SQL query to pull the necessary fields.
On the other hand, with ElasticSearch
I can't get satisfying results even after a day of reading about Fuzzy Like This Query, matching, partial matching and other. A lot of information but it does not make task easier. I feel like I need to be PhD in search just to make it work at simplest level.
So far I ended up with such configuration
{
"settings": {
"analysis": {
"analyzer": {
"stem": {
"tokenizer": "standard",
"filter": [
"standard",
"lowercase",
"stop",
"porter_stem"
]
}
}
}
},
"mappings": {
"movies": {
"dynamic": true,
"properties": {
"title": {
"type": "string",
"analyzer": "stem"
}
}
}
}
}
The Query look like this:
{
"query": {
"query_string": {
"query": "clint eastw"
"default_field": "title"
}
}
}
But quality of search in this case is not satisfying at all - back to my example, it can not find Clint Eastwood
profile until I type his name completely.
Then I tried to use
{
"query": {
"fuzzy_like_this": {
"fields": [
"title"
],
"like_text": "clint eastw",
"max_query_terms": 25,
"fuzziness": 0.5
}
}
}
It helps but not much, now I can find what I need with shorter request clint eastwo
and after some manipulations with parameters with clint eastw
but still not encouraging.
So I wonder, is there a simple recipe how to cook full-text search with ElasticSearch
and get decent quality of results. I spend a day reading but didn't find the solution.
Couple of images to demonstrate what I am talking about:
Elastic, name almost complete but no expected result, note that there is no better match as well.
One letter after, elastic found it!
At the same moment Sphinx shining :)
Elasticsearch ships with auto completion suggester. You need not put this into query functioanility , the way it works is on token level and not on partial token level. Go for completion suggester , it also have support for fuzzy logic.
这篇关于ElasticSearch:全文搜索变得容易的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!