I have the following python code which works fine, bringing me exactly 50 results as expected:
elastic = settings.ELASTIC
indexes = u'nginx-access-2769z-2018.11.26.16'
filter_by_client = [
{'match_phrase': {'client_id': '2769z'}},
]
range_for_search = {
'gte': str(1543248611),
'lte': str(1543249511),
'format': 'epoch_second',
}
query_body = {
'from': 0,
'size': 50,
'query': {
'bool': {
'must': filter_by_client,
'filter': {'range': {'@timestamp': range_for_search}},
},
}
}
search_result = elastic.search(index=indexes, body=query_body)
results = [result['_source'] for result in search_result['hits']['hits']]
And I now if I add another filter such as
...
filter_by_client = [
{'match_phrase': {'client_id': '2769z'}},
{'match': {'remote_address': '181.220.174.189'}}
]
...
It also works fine! Narrowing it down to 5 results.
My problem is: how do I query that string over all fields? Doesn't matter to me if that string is at the start/end of the field, if it is uppercase, if the field is actually an integer/float and not a string, ...
Already tried using the "_all" keyword like this
...
filter_by_client = [
{'match_phrase': {'client_id': '2769z'}},
{'match': {'_all': '181.220.174.189'}}
]
...
but it gives me 0 results. Trying to reproduce the same behaviour that happen over Kibana interface.
_allis deprecated. Use copy_to instead and query on the custom field indexed by usingcopy_toparameter.