Add from and size parameters to terms lookup query for pagination support#20923
Add from and size parameters to terms lookup query for pagination support#20923ShawnQiang1 wants to merge 1 commit into
Conversation
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit 28f7402.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit b0d26ff.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit fbb8356.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit 4ec8da0.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit 2c89aad.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit 1721ab5.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
PR Reviewer Guide 🔍(Review updated until commit 957d58f)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 957d58f
Previous suggestionsSuggestions up to commit a18cd94
|
|
❌ Gradle check result for a18cd94: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Adds pagination support for terms lookup queries via new from and size parameters in TermsLookup. Allows users to control which terms are fetched from the lookup index. Signed-off-by: Shawn Qiang <814238703@qq.com> Co-authored-by: OpenCode <support@opencode.ai>
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit 957d58f.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
|
Persistent review updated to latest commit 957d58f |
|
❌ Gradle check result for 957d58f: null Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
@navneet1v I need some advice. Currently, this paginated subquery doesn't seem to detect when the query has finished. What methods do you think we should use to inform the user that the lookup query has returned 0 records? |
@ShawnQiang1 first of all this its a good idea to add the from and size capability to terms lookup query. I don't think we should provide any support if from and size doesn't give any result. The way I am thinking about this problem is if terms lookup give no results, then query should just proceed thinking the terms provided in query is empty by the user. and based on the other query clause user might get 0 or more results. If someone want to get deeper into the query they can use explain api to understand the query. I am hoping this should provide details that terms lookup query resulted in 0 values. @ShawnQiang1 let me know if I answered your question, or I wandered in a direction far away from your original question. |
|
@navneet1v I think you're right. Pagination search does have a relatively high performance overhead. When people use it, they're usually based on the number of terms retrieved (e.g., the first 1000 terms in the query), and don't typically stop just because the result is empty. So you're correct; we can leave it as is. |
|
This PR is stalled because it has been open for 30 days with no activity. |
Description
This PR adds support for
fromandsizeparameters in terms lookup queries, enabling pagination when fetching terms from a lookup index. This is particularly useful when dealing with large lookup datasets where fetching all terms at once is not efficient or exceeds system limits.100% AI generated
Related Issues
Resolves #20865
Changes
fromandsizefields toTermsLookupclassTermsLookupconstructors, getters, setters, and builder methodsTermsQueryBuilder.fetch()to use user-specifiedfromandsizeparametersUsage Example
{ "terms": { "ASIN": { "index": "membership-index", "path": "ASIN", "query": { "term": { "userId": "user123" } }, "from": 0, "size": 10000 } } }Testing
171_terms_lookup_query.yml:sizeparameter limits number of terms fetchedfromparameter skips first N termsfromandsizeparameterssize=0returns no terms./gradlew spotlessApplyCheck List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.