PYTHON-4332 create_search_index only sends "type" field when provided (#1573)
This commit is contained in:
parent
2da8af01a6
commit
48d5a46e46
@ -592,7 +592,7 @@ class SearchIndexModel:
|
||||
self,
|
||||
definition: Mapping[str, Any],
|
||||
name: Optional[str] = None,
|
||||
type: Optional[str] = "search",
|
||||
type: Optional[str] = None,
|
||||
**kwargs: Any,
|
||||
) -> None:
|
||||
"""Create a Search Index instance.
|
||||
@ -613,7 +613,8 @@ class SearchIndexModel:
|
||||
if name is not None:
|
||||
self.__document["name"] = name
|
||||
self.__document["definition"] = definition
|
||||
self.__document["type"] = type
|
||||
if type is not None:
|
||||
self.__document["type"] = type
|
||||
self.__document.update(kwargs)
|
||||
|
||||
@property
|
||||
|
||||
@ -62,7 +62,17 @@ class TestCreateSearchIndex(IntegrationTest):
|
||||
listener.reset()
|
||||
with self.assertRaises(OperationFailure):
|
||||
coll.create_search_index({"definition": definition, "arbitraryOption": 1})
|
||||
self.assertIn("arbitraryOption", listener.events[0].command["indexes"][0])
|
||||
self.assertEqual(
|
||||
{"definition": definition, "arbitraryOption": 1},
|
||||
listener.events[0].command["indexes"][0],
|
||||
)
|
||||
|
||||
listener.reset()
|
||||
with self.assertRaises(OperationFailure):
|
||||
coll.create_search_index({"definition": definition, "type": "search"})
|
||||
self.assertEqual(
|
||||
{"definition": definition, "type": "search"}, listener.events[0].command["indexes"][0]
|
||||
)
|
||||
|
||||
|
||||
class SearchIndexIntegrationBase(unittest.TestCase):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user