保护某些短语进行搜索

时间:2012-10-17 08:14:11

标签: lucene elasticsearch

我目前正在尝试改进弹性搜索结果的极端情况。一个特别的问题让我头疼:" google +"这简直归结为" google"。省略特殊字符通常很好,但对于这个我想要一个例外。任何想法如何实现这一目标?

我尝试了以下设置:

{
  "index": {
    "analysis": {
      "analyzer": {
        "default": {
          "tokenizer": "standard",
          "filter": [
            "synonym",
            "word_delimiter"
          ]
        }
      },
      "filter": {
        "synonym": {
          "type": "synonym",
          "synonyms_path": "analysis/synonym.txt"
        },
        "word_delimiter": {
          "type": "word_delimiter",
          "protected_words_path": "analysis/protected.txt"
        }
      }
    }
  }
}

protected.txt包含一行google +

2 个答案:

答案 0 :(得分:0)

我想Standard tokenizer正在从+中删除google+。您可以使用analyze api进行检查。我会使用Whitespace tokenizer代替您正确配置您已使用的Word delimiter token filter

答案 1 :(得分:0)

相关问题