You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/index-management/index-management.rst
+184-1Lines changed: 184 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -852,6 +852,188 @@ Example::
852
852
> a
853
853
[ "_id_", "ty_1", "l_2dsphere", "ts_1" ]
854
854
855
+
--------------
856
+
SearchIndexes
857
+
--------------
858
+
859
+
Server7.0 introduced three new server commands and a new aggregation stage to facilitate management of search indexes. Drivers MUST provide
860
+
an API similar to the existing index management API specifically for search indexes. Drivers MAY choose to implement either the standard
861
+
API or the index view API.
862
+
863
+
Search Index Management Helper Options
864
+
--------------------------------------
865
+
866
+
There are currently no supported options for any of the search index management commands. To future proof
867
+
drivers implementations so that any options added in the future do not constitute a breaking change to drivers,
868
+
empty options structs have been added as placeholders. If a driver's language has a mechanism to add options
869
+
in a non-breaking manner (i.e., method overloading) drivers MAY omit the empty options structs from their
870
+
search index management helpers.
871
+
872
+
``listSearchIndexes`` is implemented using an aggregation pipeline. The list helper MUST support a driver's aggregation
873
+
options as outline in the `CRUD specification <https://github.com/mongodb/specifications/blob/master/source/crud/crud.rst#read>`_. Drivers MAY combine the aggregation options with
874
+
any future ``listSearchIndexes`` stage options, if that is idiomatic for a driver's language.
875
+
876
+
Notes
877
+
-----
878
+
879
+
The search index commands are asynchronous and return from the server before the index is successfully updated, created or dropped.
880
+
In order to determine when an index has been created / updated, users are expected to run the ``listSearchIndexes`` repeatedly
881
+
until index changes appear.
882
+
883
+
An example, from Javascript:
884
+
885
+
.. code:: typescript
886
+
887
+
const name = await collection.createSearchIndex({ definition: { ... fill out definition } })
888
+
while (!(await collection.listSearchIndexes({ name }).hasNext())) {
889
+
await setTimeout(1000);
890
+
}
891
+
892
+
CommonInterfaces
893
+
-----------------
894
+
895
+
.. code:: typescript
896
+
897
+
interfaceSearchIndexModel {
898
+
// The definition for this index.
899
+
definition:Document;
900
+
901
+
// The name for this index, if present.
902
+
name:Optional<string>;
903
+
}
904
+
905
+
/**
906
+
* The following interfaces are empty but are provided as placeholders for drivers that cannot
907
+
* add options in a non-breaking manner, if options are added in the future.
908
+
*/
909
+
interfaceCreateSearchIndexOptions {}
910
+
interfaceUpdateSearchIndexOptions {}
911
+
interfaceListSearchIndexOptions {}
912
+
interfaceDropSearchIndexOptions {}
913
+
914
+
StandardAPIforSearchIndexes
915
+
-------------------------------
916
+
917
+
.. code:: typescript
918
+
919
+
interfaceCollection {
920
+
/**
921
+
* Convenience method for creating a single search index.
922
+
*
923
+
* @return The name of the created search index
924
+
*
925
+
* @note Drivers MAY opt to implement this method signature, the signature that
926
+
* takes an SearchIndexModel as a parameter, or for those languages with method
0 commit comments