File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change 14
14
collection = database [ :movies ]
15
15
# end-sample-data
16
16
17
- # start-index-compound
18
17
# Creates an index on the "runtime" and "year" field
18
+ # start-index-compound
19
19
collection . indexes . create_one ( { runtime : -1 , year : 1 } )
20
20
# end-index-compound
21
21
22
+ # Finds a document with the specified runtime and release year by using the newly created index
22
23
# start-index-compound-query
23
- # Finds a document with the specified runtime and release year by using the
24
- # newly created index
25
24
filter = { '$and' => [
26
25
{ runtime : { '$gt' => 90 } } ,
27
26
{ year : { '$gt' => 2005 } }
35
34
end
36
35
# end-index-compound-query
37
36
38
- # start-check-compound-index
39
37
# Lists all indexes on the collection
38
+ # start-check-compound-index
40
39
puts collection . indexes . collect ( &:to_json )
41
40
# end-check-compound-index
Original file line number Diff line number Diff line change @@ -64,14 +64,15 @@ in ascending order on the ``year`` field:
64
64
:language: ruby
65
65
:copyable:
66
66
67
+ To verify the index's creation, you can list the
68
+
67
69
Verify Index Creation
68
70
---------------------
69
71
70
72
You can verify that the index was created by listing the indexes in the
71
73
collection. You should see an index for ``runtime`` and ``year`` in the list,
72
74
as shown in the following output:
73
75
74
-
75
76
.. io-code-block::
76
77
:copyable: true
77
78
You can’t perform that action at this time.
0 commit comments