@@ -18,23 +18,52 @@ knowledgeable of the latest MongoDB Documentation and uses the
18
18
MongoDB Docs Chatbot API to link users to information in addition to
19
19
the textual response.
20
20
21
- Examples
22
- ~~~~~~~~
21
+ Example
22
+ ~~~~~~~
23
23
24
- Create an Index
25
- ~~~~~~~~~~~~~~~
24
+ Consider the following prompt that asks for information on creating an
25
+ index in the GitHub Copilot chat:
26
26
27
- You can ask the |copilot| to link you to relevant MongoDB Documentation.
28
- For example, consider the following prompt in the GitHub Copilot chat :
27
+ .. code-block:: javascript
28
+ :copyable: false
29
+
30
+ @MongoDB /docs how do I create an index?
31
+
32
+ The chat first provides with the following links to MongoDB Documentation:
33
+
34
+ - `Create an Index <https://www.mongodb.com/docs/manual/core/indexes/create-index/>`__
35
+ - `createIndexes <https://mongodb.com/docs/manual/reference/command/createIndexes/>`__
36
+ - `Getting Started with MongoDB and Java - CRUD Operations Tutorial <https://www.mongodb.com/developer/languages/java/java-setup-crud-operations>`__
37
+ - `db.collection.createIndex() <https://mongodb.com/docs/manual/reference/method/db.collection.createIndex/>`__
38
+
39
+ The |copilot| also returns a textual response with information about
40
+ creating an index:
29
41
30
42
.. code-block:: javascript
31
43
:copyable: false
32
44
33
- @MongoDB /docs can you link me to documentation on creating an index?
45
+ To create an index in MongoDB, you can use the createIndex() method
46
+ in the MongoDB Shell or the equivalent method for your specific
47
+ driver. Here are examples for different programming languages:
48
+
49
+ MongoDB Shell
50
+
51
+ db.collection.createIndex({ <key and index type specification> }, { <options> })
34
52
35
- The chat responds with the following pages:
53
+ C#
36
54
37
- - G
55
+ collection.CreateIndex(IndexKeys<collection>.<key and index type
56
+ specification>, <options>);
57
+
58
+ ...
38
59
60
+ Indexes support efficient execution of queries in MongoDB. If your
61
+ application is repeatedly running queries on the same fields,
62
+ creating an index on those fields can significantly improve
63
+ performance. However, keep in mind that while indexes improve query
64
+ performance, they can negatively impact write operations due to the
65
+ additional overhead of maintaining the index.
39
66
40
-
67
+ .. figure:: /images/copilot-docs.png
68
+ :figwidth: 700px
69
+ :alt: Screenshot of copilot providing information on creating an index
0 commit comments