我有一个弹性搜索大文件
我正在搜索以下查询
{"size": 1000, "query": {"query_string": {"query": "( string1 )"}}}
假设我的string1 =产品,如果某个意外类型的产品被某个人忘记了 o
有什么办法可以搜索吗
{"size": 1000, "query": {"query_string": {"query": "( prdct )"}}}
还必须返回prdct +产品的结果
您可以使用模糊查询来返回包含与搜索词相似的词的文档。请参阅此博客以获取有关模糊查询的详细说明。
因此,您有更多的编辑距离可以匹配prdct
。模糊性参数可以定义为:
0, 1, 2
0..2 = Must match exactly
3..5 = One edit allowed
More than 5 = Two edits allowed
索引数据:
{
"title":"product"
}
{
"title":"prdct"
}
搜索查询:
{
"query": {
"fuzzy": {
"title": {
"value": "prdct",
"fuzziness":15,
"transpositions":true,
"boost": 5
}
}
}
}
搜索结果:
"hits": [
{
"_index": "my-index1",
"_type": "_doc",
"_id": "2",
"_score": 3.465736,
"_source": {
"title": "prdct"
}
},
{
"_index": "my-index1",
"_type": "_doc",
"_id": "1",
"_score": 2.0794415,
"_source": {
"title": "product"
}
}
]
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句