elasticsearch - 弹性搜索 N-gram 未返回预期结果
问题描述
试图弄清楚这个小例子的得分。我希望得到文件,brenda eaton
但我得到brenda fassie
了最好的结果。
PUT ngram
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "my_tokenizer"
}
},
"tokenizer": {
"my_tokenizer": {
"type": "ngram",
"min_gram": 3,
"max_gram": 3,
"token_chars": [
"letter",
"digit"
]
}
}
}
},
"mappings": {
"tweet" : {
"properties" : {
"text" : {
"type" : "text",
"analyzer": "my_analyzer"
}
}
}
}
}
PUT ngram/tweet/1
{
"text":"searched the blue sky during the summer"
}
PUT ngram/tweet/2
{
"text":"sdssded the trans hex during the sssss"
}
PUT ngram/tweet/3
{
"text":"searched the brenda eaton during the summer"
}
PUT ngram/tweet/4
{
"text":"sdssded the brenda fassie during the sssss"
}
GET ngram/_search
{
"query": {
"match" : {
"text" : {
"query" : "brenda eaton",
"max_expansions" : 10
}
}
}
}
解决方案
在填充索引的初始阶段,文档的相关性可能在很大程度上取决于它们在分片中的分布。尝试使用一个主分片和一个副本分片创建索引,您将获得所需的结果。
您可以在 Elasticsearch 指南的以下文章中找到对这种现象的一个很好的解释:相关性被破坏!
推荐阅读
- apache-httpclient-4.x - HttpClient5 - 更改/删除了很多 API
- javascript - 前端:使用反应中的一些设置变量访问数组中的项目
- express - 带有 msal 节点的 Azure AD:如何获取用户配置文件?
- python - 如何为流水线式多输出分类器绘制树?
- ajax - Laravel/Ajax DELETE:“在 null 上调用成员函数 delete()”
- powerbi - 添加一个工具提示,将给出特定持续时间的类别百分比
- ios - 从给定 MKMapView 的当前边界获取纬度/经度的大小
- windows - 如何直接从 Windows 10 资源管理器 GUI 使用选项 ( someprogram.exe -someoption ) 运行文件
- node.js - 如何在带有 node.js 的 ejs 文件中使用 sqlite3 数据库?
- android - 自 Android Studio 4.2 以来,没有可见的可调试进程