# Term Query fails with special charcters

**URL:** <https://discuss.elastic.co/t/term-query-fails-with-special-charcters/223813>\
**Category:** Elasticsearch\
**Created:** [March 16, 2020, 7:00pm UTC](https://discuss.elastic.co/t/term-query-fails-with-special-charcters/223813 "2020-03-16T19:00:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![smandalika](https://avatars.discourse-cdn.com/v4/letter/s/ce73a5/32.png) [@smandalika](https://discuss.elastic.co/u/smandalika)\
**Post date:** [March 16, 2020, 7:00pm UTC](https://discuss.elastic.co/t/term-query-fails-with-special-charcters/223813/1 "2020-03-16T19:00:29Z")

</div>

Term query fails with special characters.  
Input:

```auto
--header 'Content-Type: application/json' \
-d '{
            "id": "6a974e5c18b7408db76dfc11212f6d9d",
            "authId": "9900732910",
            "offeringId": "976db9ef-d3b4-4f45-bfb5-38817661e594",
            "serviceId": "PMSG",
            "subject": "This is message",
            "message": "This is message",
            "category": "unreadMessage",
            "statusCode": "UNREAD",
            "media": "INAPP_ICE",
            "statusMessage": "SUCCESS",
            "notificationHeaderId": "eed6874b-532e-4ed7-80f1-b2b36a929718",
            "expireAt": "2020-07-06",
            "createdAt": "2020-07-06",
            "updatedAt": "2020-07-06",
            "createdBy": "9059977894068481",
            "updatedBy": "9059977894068481",
            "customAttributes": {
                "sto-group": "sto_control_1.0.0",
                "sourceServiceName": "PMSG",
                "subject": "This is message",
                "topic": "oinp-ttl.Turbo Tax Live.unreadMessage"
            }
        }'

```

Query :

```auto
--header 'Content-Type: application/json' \
-d '
{
 "query" : {
 
  "bool":{
     "must":[
        {
           "term":{
              "authId":{
                 "value":"9900732910",
                 "boost":1.0
              }
           }
        },
   {
           "term":{
              "statusCode":{
                 "value":"unread",
                 "boost":1.0
              }
           }
        },
   {
           "term":{
              "customAttributes.sourceServiceName":{
                 "value":"pmsg",
                 "boost":1.0
              }
           }
        },
   {
           "term":{
              "customAttributes.topic":{
                 "value":"oinp-ttl.Turbo Tax Live.unreadMessage",
                 "boost":1.0
              }
           }
        }
     ],
     "adjust_pure_negative":true,
     "boost":1.0
  }

}
}'

```

customAttributes.sourceServiceName- success because i converted the value to lower chars.  
customAttributes.topic doesnot work however.

I checked few articles and tried to set not\_analyzed - But that works only for type=String- I have Map and its a key-value pair.. I am AWS Elastic- 7.1 version. Somewhere it said after version 6, we dont have to ser "not\_analyzed" and keyword search should happen. but I dint find any good examples for that.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [March 17, 2020, 5:33pm UTC](https://discuss.elastic.co/t/term-query-fails-with-special-charcters/223813/2 "2020-03-17T17:33:09Z")

</div>

can you please provide a full reproducible example that also contains index creation and mapping, and also make this example minimal, so that the mapping only contains the three fields from your query - same for the document. This will make your example much easier to udnerstand and grasp and increase your chances of getting help.

Thank you!

--Alex

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 14, 2020, 5:43pm UTC](https://discuss.elastic.co/t/term-query-fails-with-special-charcters/223813/3 "2020-04-14T17:43:10Z")

</div>

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