【发布时间】:2019-04-03 05:18:09
【问题描述】:
我有一些数据是从弹性搜索中搜索的,因为与 MongoDB 相比,它提供了更好的全文搜索。但我面临一些问题,其中之一是:
我在 elasticsearch 中保存的数据如下:
[{
"word": "tidak berpuas hati",
"type": "NEGATIVE",
"score": -0.3908697916666666
},{
"word": "berpuas hati",
"type": "POSITIVE",
"score": 0.65375
},{
"word": "hati",
"type": "POSITIVE",
"score": 0.6
},{
"word": "tidak",
"type": "NEGATIVE",
"score": 0.6
}]
但是当我在这个数据中搜索 saya tidak berpuas hati 句子时。我得到这样的回应:
"hits": [
{
"_index": "sentiment",
"_type": "ms",
"_id": "8SPiimYBKsyQt_Jg1VYa",
"_score": 8.838576,
"_source": {
"word": "berpuas hati",
"type": "POSITIVE",
"score": 0.65375
},
"highlight": {
"word": [
"<em>berpuas</em> <em>hati</em>"
]
}
},
{
"_index": "sentiment",
"_type": "ms",
"_id": "PiPiimYBKsyQt_Jg1U4U",
"_score": 8.774891,
"_source": {
"word": "tidak berpuas hati",
"type": "NEGATIVE",
"score": -0.3908697916666666
},
"highlight": {
"word": [
"<em>tidak</em> <em>berpuas</em> <em>hati</em>"
]
}
},
{
"_index": "sentiment",
"_type": "ms",
"_id": "ByPiimYBKsyQt_Jg1VUZ",
"_score": 5.045017,
"_source": {
"word": "hati",
"type": "POSITIVE",
"score": 0.6
},
"highlight": {
"word": [
"<em>hati</em>"
]
}
}
]
这是我的查询:
query = {
"from": 0,
"size": 20,
"query": {
"match": {
"word": {
"query": term,
"operator": 'or',
"fuzziness": 'auto'
}
}
},
"highlight": {
"fields": {
"word": {}
}
}
}
所以这里的问题是我不明白为什么tidak berpuas hati 的分数不高于berpuas hati。当我将from 的值更改为1 时,它开始为这个句子工作,并停止为单个单词句子。
【问题讨论】:
-
在这个例子中我们讨论了多少数据?你的 ES 索引有多少个分片?看看elastic.co/guide/en/elasticsearch/reference/master/…也许这可以解释你的经历。
-
我有大约 25,000 个文档和 "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }
标签: elasticsearch