From cf262c1555d19549796b2264d42926cc6030043d Mon Sep 17 00:00:00 2001 From: m-Bilal Date: Mon, 25 Nov 2024 21:04:48 +0530 Subject: [PATCH 1/3] set max result size to 100 if size > 100 --- connector/variables.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/connector/variables.go b/connector/variables.go index c049afa..dfd64f7 100644 --- a/connector/variables.go +++ b/connector/variables.go @@ -30,7 +30,15 @@ func executeQueryWithVariables(variableSets []schema.QueryRequestVariablesElem, topHits["_source"] = body["_source"] topHits["size"] = 10 if size, ok := body["size"]; ok { - topHits["size"] = size + if (size.(int)) > 100 { + // 100 is the default max result size limit (per bucket) for top_hits aggregation + // This limit can be set by changing the [index.max_inner_result_window] index level setting. + // TODO: we should read this setting and set the limit accordingly + // A `bucket` here refers to a group of documents that match a certain clause/perdicate, and the top_hits aggregation can have multiple clauses/predicates + topHits["size"] = 100 + } else { + topHits["size"] = size + } } if limit, ok := body["limit"]; ok { topHits["from"] = limit From f03cf7b79b537f348531cbe90dd1ac6046396323 Mon Sep 17 00:00:00 2001 From: m-Bilal Date: Fri, 20 Dec 2024 23:52:15 +0530 Subject: [PATCH 2/3] refactor --- connector/variables.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/connector/variables.go b/connector/variables.go index dfd64f7..8c750a6 100644 --- a/connector/variables.go +++ b/connector/variables.go @@ -14,6 +14,12 @@ func executeQueryWithVariables(variableSets []schema.QueryRequestVariablesElem, // do not to return any documents in the search results while performing aggregations variableQuery["size"] = 0 + // 100 is the default max result size limit (per bucket) for top_hits aggregation + // This limit can be set by changing the [index.max_inner_result_window] index level setting. + // TODO: we should read this setting and set the limit accordingly + // A `bucket` here refers to a group of documents that match a certain clause/perdicate, and the top_hits aggregation can have multiple clauses/predicates + const TOP_HITS_MAX_BUCKET_RESULT_SIZE = 100 + var filters []interface{} if filter, ok := body["query"]; ok { for _, variableSet := range variableSets { @@ -28,14 +34,10 @@ func executeQueryWithVariables(variableSets []schema.QueryRequestVariablesElem, topHits := make(map[string]interface{}) topHits["_source"] = body["_source"] - topHits["size"] = 10 + topHits["size"] = TOP_HITS_MAX_BUCKET_RESULT_SIZE if size, ok := body["size"]; ok { - if (size.(int)) > 100 { - // 100 is the default max result size limit (per bucket) for top_hits aggregation - // This limit can be set by changing the [index.max_inner_result_window] index level setting. - // TODO: we should read this setting and set the limit accordingly - // A `bucket` here refers to a group of documents that match a certain clause/perdicate, and the top_hits aggregation can have multiple clauses/predicates - topHits["size"] = 100 + if (size.(int)) > TOP_HITS_MAX_BUCKET_RESULT_SIZE { + topHits["size"] = TOP_HITS_MAX_BUCKET_RESULT_SIZE } else { topHits["size"] = size } From 6ff4c1f988551522df11027506ee1816a927a76a Mon Sep 17 00:00:00 2001 From: m-Bilal Date: Fri, 20 Dec 2024 23:57:38 +0530 Subject: [PATCH 3/3] add note about top_hits operator on readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 1b92932..b66d446 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,9 @@ Below, you'll find a matrix of all supported features for the Elasticsearch conn | Nested Sorting | ❌ | | | Nested Relationships | ❌ | | +> [!Note] +> Remote Relationships are currently implemented via `top_hits` operator. That operator has a default maximum result size limit of 100 rows. This is what the connector operates on. If you give the connector a higher limit, it will change that to 100 for compliance with the database. Also, since the returned result will contain only 100 rows per bucket, it may not represent the whole result. + ## Before you get Started 1. Create a [Hasura Cloud account](https://console.hasura.io)