From 4db2eb7f86fde4bdaad63703ce12e8010ad0e79b Mon Sep 17 00:00:00 2001 From: Sh1nku <42642351+Sh1nku@users.noreply.github.com> Date: Tue, 10 Dec 2024 11:19:55 +0100 Subject: [PATCH] Add examples for SolrFacetSetResult in python --- wrappers/python/solrstice/__init__.pyi | 2 +- wrappers/python/solrstice/models.pyi | 31 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/wrappers/python/solrstice/__init__.pyi b/wrappers/python/solrstice/__init__.pyi index 8f489c2..b7252c4 100644 --- a/wrappers/python/solrstice/__init__.pyi +++ b/wrappers/python/solrstice/__init__.pyi @@ -500,7 +500,7 @@ class SelectQuery: """ class CommitType(Enum): - Hard = ("Hard",) + Hard = "Hard" Soft = "Soft" class UpdateQuery: diff --git a/wrappers/python/solrstice/models.pyi b/wrappers/python/solrstice/models.pyi index c023e9e..748d78e 100644 --- a/wrappers/python/solrstice/models.pyi +++ b/wrappers/python/solrstice/models.pyi @@ -10,6 +10,16 @@ class SolrFacetSetResult: Gets the query facets :return: The query facets + + >>> from solrstice import AsyncSolrCloudClient, SolrServerContext, SelectQuery, FacetSetComponent, FacetSetComponent + >>> client = AsyncSolrCloudClient(SolrServerContext('localhost:8983')) + >>> async def query_select() -> None: + ... select_builder = SelectQuery(facet_set=FacetSetComponent(queries=["age:[0 TO 59]"])) + ... response = await client.select(select_builder, "example_collection") + ... facets = response.get_facet_set() + ... queries = facets.get_queries() + ... query = queries.get("age:[0 TO 59]") + """ pass @@ -18,6 +28,16 @@ class SolrFacetSetResult: Gets the pivot facets :return: The pivot facets + + >>> from solrstice import FacetSetComponent, PivotFacetComponent, SelectQuery, SolrServerContext, AsyncSolrCloudClient + >>> client = AsyncSolrCloudClient(SolrServerContext('localhost:8983')) + >>> async def pivot_select() -> None: + ... select_builder = SelectQuery(facet_set=FacetSetComponent(pivots=PivotFacetComponent(["interests,age"]))) + ... response = await client.select(select_builder, "example_collection") + ... facets = response.get_facet_set() + ... pivots = facets.get_pivots() + ... interests_age = pivots.get("interests,age") + """ pass @@ -26,6 +46,17 @@ class SolrFacetSetResult: Gets the field facets :return: The field facets + + >>> from solrstice import FacetSetComponent, FieldFacetComponent, FieldFacetEntry, SelectQuery, SolrServerContext, AsyncSolrCloudClient + >>> client = AsyncSolrCloudClient(SolrServerContext('localhost:8983')) + >>> async def field_facet_select() -> None: + ... facet_set = FacetSetComponent(fields=FieldFacetComponent(fields=[FieldFacetEntry("age")])) + ... select_builder = SelectQuery(facet_set=facet_set) + ... response = await client.select(select_builder, "example_collection") + ... facets = response.get_facet_set() + ... fields = facets.get_fields() + ... age = fields.get("age") + """ class SolrPivotFacetResult: