Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

track_total_hits support? #666

Open
Zuckonit opened this issue Nov 21, 2019 · 4 comments
Open

track_total_hits support? #666

Zuckonit opened this issue Nov 21, 2019 · 4 comments

Comments

@Zuckonit
Copy link

No description provided.

@panickery
Copy link

panickery commented Feb 7, 2020

Very Late But I Found one trick about this.
For Example for SearchResult Class
build searchBuilder like this

Search search = new Search.Builder(query).addIndex("*").addCleanApiParameter("?rest_total_hits_as_int=true").build();

search.getURI() ::: */_search/?rest_total_hits_as_int=true

and when search execute
there's result

result.getJsonString() ::: {"took":0,"timed_out":false,"_shards":{"total":0,"successful":0,"skipped":0,"failed":0},"hits":{"total":0,"max_score":0.0,"hits":[]}}

@Zuckonit
Copy link
Author

Zuckonit commented Feb 7, 2020

thanks, better if trackTotalHits provided like trackScores

@panickery
Copy link

panickery commented Feb 7, 2020

Oh!! Sorry.. I answered wrong answer...
You wanted set some value 'track_total_hits' key..
You're right..
Search search = new Search.Builder(query).addIndex("*").addCleanApiParameter("?rest_total_hits_as_int=true&track_total_hits=100")
.build()

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"[rest_total_hits_as_int] cannot be used if the tracking of total hits is not accurate, got 100"}],"type":"illegal_argument_exception","reason":"[rest_total_hits_as_int] cannot be used if the tracking of total hits is not accurate, got 100"},"status":400}

It doen't work
sorry good luck!!

@debuggerhu
Copy link

@panickery Hi,

I tried this method, but I reported it wrong.The error message is as follows

Result: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"[rest_total_hits_as_int] cannot be used if the tracking of total hits is not accurate, got 50000"}],"type":"illegal_argument_exception","reason":"[rest_total_hits_as_int] cannot be used if the tracking of total hits is not accurate, got 50000"},"status":400}, isSucceeded: false, response code: 400, error message: {"root_cause":[{"type":"illegal_argument_exception","reason":"[rest_total_hits_as_int] cannot be used if the tracking of total hits is not accurate, got 50000"}],"type":"illegal_argument_exception","reason":"[rest_total_hits_as_int] cannot be used if the tracking of total hits is not accurate, got 50000"}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants