'How do I get a percolator query to use the same analyzer as the mapped fields?

I have some customized analyzer settings:

{
  "number_of_shards": %s,
  "number_of_replicas": %s,
  "analysis": {
    "filter": {
      "lowercase_mixed_case": {
        "type": "condition",
        "filter": [ "lowercase" ],
        "script": {
          "source": "!token.getTerm().toString().equals(token.getTerm().toString().toUpperCase())"
        }
      },
      "hashtag_as_alphanum" : {
        "type" : "word_delimiter",
        "type_table": ["# => ALPHANUM", "@ => ALPHANUM"]
      }
    },
    "analyzer": {
      "default_old_backup": {
        "tokenizer": "standard",
        "filter": [
          "lowercase_mixed_case"
        ]
      },
      "default" : {
        "type" : "custom",
        "tokenizer" : "whitespace",
        "filter" : ["lowercase_mixed_case", "hashtag_as_alphanum"]
      },
      "phrase_wildcard": {
        "type": "custom",
        "tokenizer": "keyword",
        "filter": []
      }
    }
  },
  "index.max_ngram_diff": 10
}

The one in question is the "default" analyzer, which is used for most text fields. Now, the text fields seems to index right for the data documents, both when sending in to be stored, and when used in a percolator query (they are stored in all "lowercase" if mixed, and all "UPPERCASE" if its already so). The text in the actual search query, which is stored as perolator documents does not seem to use the same analyzer.

IE: The queried data doc from the mapped data has field "somefield": "Foo", but is analyzed as "foo". The percolator query indexed uses "query_string": { "query": "Foo"... but is unchanged as "Foo". So it is not a match. If I change text in the percolator query to be lowercase its a match.

All this seems to indicate that text inside the percolator query and text field is analyzed differently.

Is it working as intended, or am I missing something? I could just modify the text in the percolator queries between user and ES, but I feel like ES should be able to fix this for me...



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source