@@ -101,6 +101,7 @@ def create(config: Config,
101101 wait_for_readiness : bool = True ,
102102 text_chunk_prefix : Optional [str ] = None ,
103103 text_query_prefix : Optional [str ] = None ,
104+ collapse_fields : Optional [List [marqo_index .CollapseField ]] = None ,
104105 ) -> Dict [str , Any ]:
105106 """Create the index. Please refer to the marqo cloud to see options for inference and storage node types.
106107 Creates CreateIndexSettings object and then uses it to create the index.
@@ -137,6 +138,7 @@ def create(config: Config,
137138 number_of_inferences: number of inferences for the index
138139 number_of_shards: number of shards for the index
139140 number_of_replicas: number of replicas for the index
141+ collapse_fields: list of fields that can be collapsed on at query time
140142 Note:
141143 wait_for_readiness, inference_type, storage_class, number_of_inferences,
142144 number_of_shards, number_of_replicas are Marqo Cloud specific parameters,
@@ -166,6 +168,7 @@ def create(config: Config,
166168 annParameters = ann_parameters ,
167169 textChunkPrefix = text_chunk_prefix ,
168170 textQueryPrefix = text_query_prefix ,
171+ collapseFields = collapse_fields ,
169172 )
170173 return req .post (f"indexes/{ index_name } " , body = local_create_index_settings .generate_request_body ())
171174
@@ -195,6 +198,7 @@ def create(config: Config,
195198 storageClass = storage_class ,
196199 textChunkPrefix = text_chunk_prefix ,
197200 textQueryPrefix = text_query_prefix ,
201+ collapseFields = collapse_fields ,
198202 )
199203
200204 response = req .post (f"indexes/{ index_name } " , body = cloud_index_settings .generate_request_body ())
@@ -228,7 +232,8 @@ def search(self, q: Optional[Union[str, dict]] = None, searchable_attributes: Op
228232 language : Optional [str ] = None ,
229233 sort_by : Optional [dict ] = None ,
230234 relevance_cutoff : Optional [dict ] = None ,
231- interpolation_method : Optional [str ] = None
235+ interpolation_method : Optional [str ] = None ,
236+ collapse_fields : Optional [List [dict ]] = None ,
232237 ) -> Dict [str , Any ]:
233238 """Search the index.
234239
@@ -275,6 +280,7 @@ def search(self, q: Optional[Union[str, dict]] = None, searchable_attributes: Op
275280 sort_by: a dictionary of the sort_by parameters to be used for sorting the results
276281 relevance_cutoff: a dictionary of the relevance cutoff parameters
277282 interpolation_method: the interpolation method to use for combining query & context embeddings.
283+ collapse_fields: a list of fields to collapse/group on
278284
279285 Returns:
280286 Dictionary with hits and other metadata
@@ -317,7 +323,8 @@ def search(self, q: Optional[Union[str, dict]] = None, searchable_attributes: Op
317323 "language" : language ,
318324 "sortBy" : sort_by ,
319325 "relevanceCutoff" : relevance_cutoff ,
320- "interpolationMethod" : interpolation_method
326+ "interpolationMethod" : interpolation_method ,
327+ "collapseFields" : collapse_fields ,
321328 }
322329
323330 body = {k : v for k , v in body .items () if v is not None }
0 commit comments