You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently total response is capped at 10,000 since that's the maximum default. This appears to be due to a breaking changed that was made in ElasticSsearch 7.x which added "track_total_hits": true as an option. When set to false (and the current default) it is capped to 10,000, mainly from what I can understand due to performance tuning since to derive the accurate count you have to hit every record that is match vs 10,000 and stop. Reading through the documentation it also appears to be able to accept an Int to manually override the number of tracked hits.
Add an additional option to the @searchable directive- for example @searchable(trackTotalHits: true) to allow end user to specify the expected behavior. This'll allow the total field to return an accurate count.
Since track_total_hits can also accept a number possibly allow for setting the maximum tracked hits - for example @searchable(trackTotalHits: 25000) would limit the total tracked hits returned to 25,000
This'll allow end users to be as granular as needed for their own performance tuning/needs and not cause any breaking changes since it's an optional param that defaults to false currently.
Changes required appear to be in both amplify-graphql-searchable-transformer and the graphql-mapping-template from a quick look into the code.
Describe alternatives you've considered
Since I'm using Amplify the current solution is to manually override the generated .vtl resolver to include "track_total_hits": true, in the request to OpenSearch, as shown below.
I understand the general concept of what will be needed to add this feature request, only uncertainties are regarding getting values from the directive and brining that into the function for generating the .vtl resolver. With a bit of guidance I could most likely figure this out and implement it.
Is this something that you'd be interested in working on?
👋 I may be able to implement this feature request
Would this feature include a breaking change?
⚠️ This feature might incur a breaking change
The text was updated successfully, but these errors were encountered:
MtthwBrwng
changed the title
Add Option for "track_total_hits" for AppSync Searchable Template
Add Option for "track_total_hits" on AppSync Searchable Template
Dec 8, 2022
Hey @MtthwBrwng, thanks for opening this feature request! Glad to see that manually editing the resolver to include track_total_hits did work! I'll bring this to the team's attention to discuss internally and see if this can be the default behavior.
Describe the feature you'd like to request
Currently
total
response is capped at 10,000 since that's the maximum default. This appears to be due to a breaking changed that was made in ElasticSsearch 7.x which added"track_total_hits": true
as an option. When set to false (and the current default) it is capped to 10,000, mainly from what I can understand due to performance tuning since to derive the accurate count you have to hit every record that is match vs 10,000 and stop. Reading through the documentation it also appears to be able to accept anInt
to manually override the number of tracked hits.Elastic Search Track Total Hit Docs
Describe the solution you'd like
Add an additional option to the
@searchable
directive- for example@searchable(trackTotalHits: true)
to allow end user to specify the expected behavior. This'll allow thetotal
field to return an accurate count.Since
track_total_hits
can also accept a number possibly allow for setting the maximum tracked hits - for example@searchable(trackTotalHits: 25000)
would limit the total tracked hits returned to 25,000This'll allow end users to be as granular as needed for their own performance tuning/needs and not cause any breaking changes since it's an optional param that defaults to false currently.
Changes required appear to be in both
amplify-graphql-searchable-transformer
and thegraphql-mapping-template
from a quick look into the code.Describe alternatives you've considered
Since I'm using Amplify the current solution is to manually override the generated
.vtl
resolver to include"track_total_hits": true,
in the request to OpenSearch, as shown below.Additional context
I understand the general concept of what will be needed to add this feature request, only uncertainties are regarding getting values from the directive and brining that into the function for generating the
.vtl
resolver. With a bit of guidance I could most likely figure this out and implement it.Is this something that you'd be interested in working on?
Would this feature include a breaking change?
The text was updated successfully, but these errors were encountered: