0

I'm using the following mapping:

"letters": {
    "mappings": {
       "letter": {
          "properties": {
            "destCode": {
               "type": "string",
               "index": "not_analyzed"
            },
            "tag": {
               "type": "string",
               "index": "not_analyzed"
            }
         }
      }
   }
}

My docs contains two fields:

  • tag: mostly alphanumeric and may contain some '/' or '@'chars
  • destCode: 99% a numeric string

The following query_String (i know wildcards are bad):

"query": {
    "query_string": {
        "default_field": "destCode",
        "query": "*604"
    }   
} 

correctly matches 0144604, 4521604 destCode values.

But it doesn't work for tag field, for ex the query:

"query": {
    "query_string": {
        "default_field": "tag",
        "query": "CDG*" 
    }   
} 

does not match values: CDG711892, CDG88978 and i also tried lowercase cdg* without success.

1
  • @mfundi Can you provide us with some sample documents? Commented Dec 26, 2016 at 22:14

1 Answer 1

1

In the mapping you set the field as not analyzed, because of that when you index data, elasticsearch don't analyzed it,because of that if you index data as lowercase you will not hit nothing if you search uppercase. Remove

index": "not_analyzed

And it will work

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.