Posts

Showing posts with the label elasticsearch-aggregation

How to perform search query on two different data types?

Image
Clash Royale CLAN TAG #URR8PPP How to perform search query on two different data types? my query is very simple, for the sake of even making it simpler, lets say I only search on two fields, name(text) & age(long): GET person_db/person/_search { "query": { "bool": { "should": [ { "match_phrase_prefix": { "name": "hank" } }, { "match_phrase_prefix": { "age": "hank" } } ], "minimum_should_match": 1, "boost": 1.0 } } } if I search for "23", no problem, elastic knows how to change it to numeric and it won't fail, but if the search input is "john" I get error 400 "reason": "failed to create query: {n "bool...." . "reason": "failed to create query: {n "bool...." what should I...

how to add to different field values and store it in another field in elastic search python (elastic search field operation)

Image
Clash Royale CLAN TAG #URR8PPP how to add to different field values and store it in another field in elastic search python (elastic search field operation) I have written this elastic search query: es.search(index=['ind1'],doc_type=['doc']) I am getting following result: {'_shards': {'failed': 0, 'skipped': 0, 'successful': 5, 'total': 5}, 'hits': {'hits': [{'_id': '1327', '_index': 'ind1', '_score': 1.0, '_source': {'val1': 1, 'val2': None, 'value1': 1327, 'value2': 1531, 'new_values': {'nv1': 1, 'nv2': 0}, {'_id': '1349', '_index': 'ind1', '_score': 1.0, '_source': {'val1': 2, 'val2': 3, 'value1': 1328, 'value2': 1539, 'new_values': {'nv1': 1, 'nv2': 3}},....... I want all the add val1, value1 and...