Elastic Search with Special Characters

I am using Elastic search api for python to pull some data for creating my own dashboards, Its working for several queries/dashboards no issues. But this below query string some how it's not returning any results or giving me the errors from Elastic search api from my python script, however I am able to query from Firefox browser without any issues and got the data back.

I know there might be issue with

{"query": "NOT source:"p_prodsearchwww3"", "analyze_wildcard": "true"}

If I replaced this {"query": "*", "analyze_wildcard": "true"} with above one its rerturning data.

I also did a escape like

{"query": "NOT source:"p_prodsearchwww3"", "analyze_wildcard": "true"}

But its not working.

Here is the code from my python script:

es = Elasticsearch([{'host': 'X.X.X.X', 'port': 9200}], http_auth=('user', 'pass'))
res = es.search(request_timeout=300, index="my_index-*", body=query_string)

any one know what am I missing?

http://es_server:9200/my_index_logs-/_search?source={"query": {"bool": {"must": [{"query_string": {"query": "NOT source:"p_prodsearchwww3"", "analyze_wildcard": "true"}}, {"query_string": {"analyze_wildcard": "true", "query": ""}}, {"range": {"log_timestamp": {"gte": "1532529061000", "lte": "1533738661000", "format": "epoch_millis"}}}], "must_not": []}}, "size": 0, "_source": {"excludes": []}, "aggs": {"2": {"date_histogram": {"field": "log_timestamp", "interval": "30s", "time_zone": "America/Chicago", "min_doc_count": 1},"aggs": {"3": {"terms": {"field": "class.keyword", "size": 5, "order": {"_count": "desc"}}}}}}, "version": "true", "highlight": {"pre_tags": ["@kibana-highlighted-field@"], "post_tags": ["@/kibana-highlighted-field@"], "fields": {"": {"highlight_query": {"bool": {"must": [{"query_string": {"query": "NOT source:"p_prodsearchwww3"", "analyze_wildcard": "true", "all_fields": "true"}}, {"query_string": {"analyze_wildcard": "true", "query": "", "all_fields": "true"}}, {"range": {"log_timestamp": {"gte": "1532529061000", "lte": "1533738661000", "format": "epoch_millis"}}}], "must_not": []}}}}, "fragment_size": 2147483647}}

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