简体   繁体   English

弹性搜索小写分析器不返回搜索结果

[英]Elastic Search Lowercase analyser does not return search result

I have a text based index like below.我有一个如下所示的基于文本的索引。 I am trying to maintain both exact search and ambiguous search based on tokens based on user input.我正在尝试基于用户输入的令牌维护精确搜索和模糊搜索。 While text based search works fine(partial search) when it comes to term search it returns data iff case is the same.虽然基于文本的搜索工作正常(部分搜索),但当涉及到术语搜索时,它会返回数据,前提是大小写相同。 I did try adding a lowercase filter based analyzer but it does not help.我确实尝试添加一个基于小写过滤器的分析器,但它没有帮助。 What can I do here?我可以在这里做什么?

Mappings:映射:

"project_title": {
    "type": "text",
    "fields": {
      "keyword": {
        "type": "keyword",
        "ignore_above": 256
      }
    }
  },
  "projectabstract": {
    "type": "text",
    "fields": {
      "keyword": {
        "type": "keyword",
        "ignore_above": 256
      }
    }
  },

New index based on lowercase analyzer:基于小写分析器的新索引:

PUT /project_term_search_text_analyzer
{
  "settings": {
    "analysis": {
      "analyzer": {
        "rebuilt_standard": {
          "tokenizer": "standard",
          "filter": [
            "lowercase"       
          ]
        }
      }
    }
  },
  "mappings": {"project_title": {
    "type": "text",
    "fields": {
      "keyword": {
        "type": "keyword",
        "ignore_above": 256
      }
    }
  },
  "projectabstract": {
    "type": "text",
    "fields": {
      "keyword": {
        "type": "keyword",
        "ignore_above": 256
      }
    }
  },}

How should I update my index to work in both cases.我应该如何更新我的索引以在这两种情况下工作。

You need to use the normalizer which works on the keyword fields.您需要使用适用于关键字字段的规范器。 You can also customize your normalizer like analyzer, In the link you can find the relevant example with lowercase filter, which would solve your issue.您还可以像分析器一样自定义规范化器,在链接中您可以找到带有小写过滤器的相关示例,这将解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM