Frank Conry
Frank Conry

Reputation: 2716

OpenSearch Python - Return hit count by index

I have two indices in OpenSearch that I am searching and want to do get window function like totals for each index in addition to the results. They are called users and posts and I need to get the total number of hits from posts and the total from users as well as search results that are ordered by _score or, possibly by another sorting mechanism.

I can search both indices by hitting users,posts/_search but the hits object I get back doesn't break out the totals, it just looks like this:

{'total': {'value': 28, 'relation': 'eq'}, 'max_score': 8.996178, '_hits': [ ... ]}

I want something that will give me totals per index. If its relevant I use the OpenSearch-py client and the call I'm currently making looks like this:

client.search(body=body, index='users,posts', pretty=True)

Upvotes: 0

Views: 28

Answers (0)

Related Questions