简体   繁体   中英

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.

在此处输入图片说明 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.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM