Skip to content

Commit

Permalink
Get random hits when filtering properties
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvkaliraman7 committed Feb 24, 2025
1 parent 2d0f0aa commit 572e699
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/sycamore/sycamore/query/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ def get_schema(self) -> OpenSearchSchema:
logger.debug(f"Getting schema for index {self._index}")
# Fetch example values.
query["index"] = self._index
query["query"] = {"query": {"match_all": {}}, "size": self.NUM_EXAMPLES}
query["query"] = {
"query": {"match_all": {}},
"size": self.NUM_EXAMPLES,
"sort": [{"_script": {"type": "number", "script": {"source": "Math.random()"}}}],
}
random_sample = self._query_executor.query(query)["result"]["hits"]["hits"]

result = OpenSearchSchema(
Expand Down

0 comments on commit 572e699

Please sign in to comment.