Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Searching through multiple index yielding 0 documents in elasticsearch-py

I have a search query to make across multiple indexes. To enable this as per the documentation, I need to provide a comma-separated list of indexes.

enter image description here But when I try to do it as: es.search(index='index1,index2',body=body)

I get no result: {u'hits': {u'hits': [], u'total': 0, u'max_score': None}, u'_shards': {u'successful': 10, u'failed': 0, u'skipped': 0, u'total': 10}, u'took': 1, u'timed_out': False}

However, index='_all' works to search across all index. Am I doing something incorrectly here or is there some issue with this functionality? Thanks.

like image 728
Amogh Mishra Avatar asked Dec 14 '22 12:12

Amogh Mishra


1 Answers

According to the documentation posted by you:

  • index a comma separated list... (enphasys is mine)

In your code you pass a string:

es.search(index='index1,index2',body=body)

So you should simply:

es.search(index=['index1','index2'],body=body)
like image 184
Lupanoide Avatar answered Apr 28 '23 04:04

Lupanoide