# Elastic Search with Unicode behaves abruptly with python

**URL:** <https://discuss.elastic.co/t/elastic-search-with-unicode-behaves-abruptly-with-python/149166>\
**Category:** Elasticsearch\
**Created:** [September 19, 2018, 5:35pm UTC](https://discuss.elastic.co/t/elastic-search-with-unicode-behaves-abruptly-with-python/149166 "2018-09-19T17:35:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mayank\_Kumar\_Arora](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@Mayank\_Kumar\_Arora](https://discuss.elastic.co/u/Mayank_Kumar_Arora)\
**Post date:** [September 19, 2018, 5:35pm UTC](https://discuss.elastic.co/t/elastic-search-with-unicode-behaves-abruptly-with-python/149166/1 "2018-09-19T17:35:06Z")

</div>

When I am using elasticsearch with python for unicode characters, I am seeing some unusual result. When we pass the query in a variable it results in No Records Found. But when we pass the query as it is in body part as mentioned in 1st example below, it gives correct result.

1-

```auto
result_set = self._elasticsearch_conn_instance.search(index='{0}'.format(self._my_index), \
                                                                  size=MAX_RECORD_PER_QUERY, \
                                                                  body={"query":{"constant_score":{"filter":{"bool":{"must": [{"term":{"NAME":"çãoSc"}}, {"term":{"OP":"Create"}}]}}}}}, \
                                                                  sort='OP:asc,SNAP:asc')

```

2-

```auto
result_set = self._elasticsearch_conn_instance.search(index='{0}'.format(self._dir_index), \
                                                                  size=MAX_RECORD_PER_QUERY, \
                                                                  body=computed_query, \
                                                                  sort='OP:asc,SNAPID:asc')

```

Note: In 2nd query 'computed\_query' which is getting passed as body is assigned same query as in part of 1st.

1st one passes and gives correct result but the 2nd fails and says No Record Found. This case is only with Special Unicode characters and not with ASCII characters.

How can I get the correct result with 2nd query as well ?

Any help on this behavior would be useful. Thanks !!!

---

<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:** [October 17, 2018, 5:36pm UTC](https://discuss.elastic.co/t/elastic-search-with-unicode-behaves-abruptly-with-python/149166/2 "2018-10-17T17:36:08Z")

</div>

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