elasticsearch - Elasticsearch:带空格的自动完成搜索示例不起作用
问题描述
目标:
如果我有一个带有 title 的文档The Hitchhikers Guide
,则以下搜索会显示该文档:
hitch
the hit
hitchhikers gu
以下搜索不会显示该文档:
hiker
uid
guide th
我正在关注这篇文章: https ://medium.com/@davedash/writing-a-space-ignoring-autocompleter-with-elasticsearch-6c3c28e3a974
但我似乎无法在索引/分析步骤中获得预期的结果。我在 ES 5.3 和 6.3 上试过这个。
这是我到目前为止所拥有的:
我的映射:
把我的测试
{
"settings" : {
"index":{
"analysis":{
"filter": {
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": "1",
"max_gram": "30"
},
"autocomplete_word_joiner": {
"type": "word_delimiter",
"catenate_all": true
}
},
"analyzer":{
"product_name_autocomplete_analyzer": {
"type": "custom",
"tokenizer": "keyword",
"filter": [
"lowercase",
"autocomplete_word_joiner",
"autocomplete_filter"
]
}
}
}
}
},
"mappings" : {
"doc" : {
"properties": {
"name": {
"type": "text",
"store": true,
"analyzer": "product_name_autocomplete_analyzer",
"term_vector": "with_positions_offsets"
}
}
}
}
}
然后测试分析仪:
发布 my_test/_analyze
{
"analyzer": "product_name_autocomplete_analyzer",
"text": "the hitchhikers guide"
}
以下是代币:
t
th
the
theh
thehi
thehit
...
thehitchikersguid
thehitchikersguide
h
hi
hit
hitc
hitch
...
hitchiker
hitchikers
g
gu
...
guide
这是出乎意料的,因为它丢失hitchhikersg
了hitchhikersgu
等
这意味着搜索hitchhikers gu
失败,这就是我所看到的。
有什么建议吗?
解决方案
推荐阅读
- android - Java android google maps 显示所有标记和 InfoWindows
- c# - 嵌套属性不调用自定义 JsonConverter
- ruby-on-rails - rails如何在更新新密码之前验证旧密码
- python - Python 不使用 if 子句选择函数的正确部分
- mysql - 使用 ORDERBY 时的 MySQL 慢 JOIN 查询
- python - 从 S3 读取文件 - Pyspark
- angular - Angular - 如何动态加载 templateUrl?
- python-2.7 - 在 Google Cloud IoT Core 中创建客户端的两种方式有什么区别?
- angular - (茉莉花)如何以编程方式选择/传递值
- python - Python RASA - 导入“from rasa_core.agent import Agent”时出现错误“object()不带参数”