Elasticsearch可以归还一个“成功的”模糊木瓦吗?

时间:2016-05-07 13:20:10

标签: elasticsearch fuzzy-search shingles

TL; DR

是否可以让Elasticsearch在模糊查询中返回匹配的输入 -shingle和匹配的文档?

示例:

让我说我有一个瓦:

"fulltext_shingle_filter":{
  "type": "shingle",
  "min_shingle_size": 2,
  "max_shingle_size": 3,
  "output_unigrams": false
}

那个木瓦用于自定义搜索分析器:

"fulltext_shingle":{
  "type": "custom",
  "tokenizer": "standard",
  "filter":["fulltext_shingle_filter"]
}

将索引分析为关键字,如:

"whitelist_keyword": {
  "type": "custom",
  "tokenizer": "keyword"
}

文档看起来像这样:

{
"_source": {
  "names": [
    "John Smith",
    "Smith, John"
  ]
},
{
"_source": {
  "names": [
    "Mr Wayne"
  ]
}

我们这样查询:

POST /someindex/_search
{
  "query": {
    "match": {
    "names": {
      "query": "Hi, my Name is John Smit, I like toast.",
      "analyzer": "fulltext_shingle",
      "fuzziness": 1
      }
    }
  }
}

这将使用我们的fulltext_shingle-analyzer分割查询,并将1的模糊度应用于“John Smit”。然后Elasticsearch返回包含“John Smith”的文档,因为Levenshtein-Distance等于1.

现在,是否有可能让elasticsearch返回在模糊测试之前使用的输入木瓦,即“John Smit”和匹配的文档?

我唯一能想到的就是基本上反转查询,即在启用了带状疱疹的情况下索引查询文档,然后查询具有相同模糊性的原始输出(“John Smith”)。但这对我来说似乎是一个非常容易出错且浪费资源的麻烦。

0 个答案:

没有答案