确定在模糊搜索中哪些词匹配 [英] Determining which words were matched in a fuzzy search

查看:110
本文介绍了确定在模糊搜索中哪些词匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在进行模糊搜索,需要查看哪些词匹配。例如,如果我正在搜索测试的查询,并且它与一个字段与句子匹配。男孩休息我需要知道匹配是由于休息

I'm running a fuzzy search, and need to see which words were matched. For example, if I am searching for the query testing, and it matches a field with the sentence The boy was resting, I need to be able to know that the match was due to the word resting.

我尝试设置参数 explain = true ,但它似乎不包含我需要的信息。任何想法?

I tried setting the parameter explain = true, but it doesn't seem to contain the information I need. Any thoughts?

推荐答案

好的,这是我正在寻找的:

Alright, this is what I was looking for:

经过一番研究,我发现突出显示功能

After a bit of research, I found the Highlighting feature of elasticsearch.

默认情况下,它返回匹配项的上下文片段,但您可以将片段大小设置为查询长度,以仅返回完全匹配项。例如:

By default it returns a snippet of context surrounding the match, but you can set the fragment size to the query length to return only the exact match. For example:

{
    query : query,
    highlight : {
        "fields" : {
            'text' : {
                "fragment_size" : query.length
            }
        }
    }
}

这篇关于确定在模糊搜索中哪些词匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆