How to determine if a field is analyzed or not_analyzed?


#1

must: { term: { ... }} fails but must: { match: { ... }} has hits.

  1. term will only work for not_analyzed fields, correct?
  2. How can I see if a field is not_analyzed?

(David Pilato) #2
  1. No.

term will work without applying any analysis transformation to your request.

Which means that it can also work against a analyzed or not analyzed field.

For example, if you index with a standard analyzer the following text: BrOWN foX and you search with a term query for fox or brown, it will find the doc.

If you search for BrOWN it won't match.

  1. GET index/_mapping

#3

I performed this request:

GET /_all

From there I could see the field isn't analyzed as expected.

          "request": {
            "type": "string",
            "norms": {
              "enabled": false
            },
            "fielddata": {
              "format": "disabled"
            },
            "fields": {
              "raw": {
                "type": "string",
                "index": "not_analyzed",
                "ignore_above": 256
              }
            }

@dadoonet GET logstash-2016.07.04/_mapping worked as well.

I'm not sure why must: { term: { ... }} fails, but I suppose that's another question.


(David Pilato) #4

My guess is that your query is wrong.

If you send a full script to reproduce that, I can explain what is happening.


(system) closed #5