How to properly use asterisk with keywords_pattern?


(Иван Сорокин) #1

I want to use this but I can't understand how to write valid keywords_pattern. I modify code from example like this

{
  "settings": {
    "analysis": {
      "analyzer": {
        "protect_cats": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": ["lowercase", "protect_cats", "porter_stem"]
        },
        "normal": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": ["lowercase", "porter_stem"]
        }
      },
      "filter": {
        "protect_cats": {
          "type": "keyword_marker",
          "keywords_pattern": ".*\\*"
        }
      }
    }
  }
}

and put this to test_index via put request. I expected elasticsearch to return token "cats*" or at least "cats" after executed "/_analyze?text=cats*&analyzer=protect_cats" but I got "cat" instead. How to achieve desired result? Thanks.


(Mike Barretta) #2

@7ca884569f2642e2c488
I think your problem is with the standard tokenizer. If you switch to the whitespace tokenizer, that should work.


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.