@@ -37,7 +37,7 @@ To learn more about the ``$search`` pipeline stage, see :manual:`$search
37
37
The examples in this guide use the following documents in a collection called
38
38
``guitars``:
39
39
40
- .. code-block:: json
40
+ .. code-block:: text
41
41
42
42
{ "_id": 1, "make": "Fender", "description": "Classic guitars known for their versatility.", "establishedYear": 1946, "in_stock": true, "rating": 9 }
43
43
{ "_id": 2, "make": "Gibson", "description": "Classic guitars known for their rich, full tones.", "establishedYear": 1902, "in_stock": true, "rating": 8 }
@@ -108,7 +108,7 @@ collection using the string "Gib" in the ``make`` field.
108
108
109
109
The search returns the following document:
110
110
111
- .. code-block:: json
111
+ .. code-block:: text
112
112
113
113
{ "_id" : 2, "make" : "Gibson", "description" : "Classic guitars known for their rich, full tones.", "establishedYear" : 1902, "in_stock" : true, "rating" : 8 }
114
114
@@ -136,7 +136,7 @@ that match all of the following criteria:
136
136
137
137
The search returns the following documents:
138
138
139
- .. code-block:: json
139
+ .. code-block:: text
140
140
141
141
{ "_id" : 1, "make" : "Fender", "description" : "...", "establishedYear" : 1946, "in_stock" : true, "rating" : 9 }
142
142
{ "_id" : 3, "make" : "PRS", "description" : "...", "establishedYear" : 1985, "in_stock" : true, "rating" : 9 }
@@ -186,7 +186,7 @@ and returns any documents with a ``serial`` field value of ``"YZ5678"``:
186
186
187
187
The search returns the following document:
188
188
189
- .. code-block:: json
189
+ .. code-block:: text
190
190
191
191
{ "_id" : 1, "make" : "Fender", "description" : "Classic guitars known for their versatility.", "establishedYear" : 1946, "in_stock" : true, "rating" : 9, "productDetails" : [{ "product_id" : 1234, "serial" : "YZ5678" }] }
192
192
@@ -210,7 +210,7 @@ which the value of the ``in_stock`` field is ``true``.
210
210
211
211
The search returns the following documents:
212
212
213
- .. code-block:: json
213
+ .. code-block:: text
214
214
215
215
{ "_id" : 1, "make" : "Fender", "description" : "...", "establishedYear" : 1946, "in_stock" : true, "rating" : 9 }
216
216
{ "_id" : 2, "make" : "Gibson", "description" : "...", "establishedYear" : 1902, "in_stock" : true, "rating" : 8 }
@@ -239,7 +239,7 @@ which the ``rating`` field exists.
239
239
240
240
The search returns the following documents:
241
241
242
- .. code-block:: json
242
+ .. code-block:: text
243
243
244
244
{ "_id" : 1, "make" : "Fender", "description" : "...", "establishedYear" : 1946, "in_stock" : true, "rating" : 9 }
245
245
{ "_id" : 2, "make" : "Gibson", "description" : "...", "establishedYear" : 1902, "in_stock" : true, "rating" : 8 }
@@ -282,7 +282,7 @@ polygon:
282
282
283
283
The search returns the following document:
284
284
285
- .. code-block:: json
285
+ .. code-block:: text
286
286
287
287
{ "_id" : 1, "make" : "Fender", "description" : "...", "establishedYear" : 1946, "in_stock" : true, "in_stock_location" : { "type" : "Point", "coordinates" : ["-73.93615", "40.69791"] }, "rating" : 9 }
288
288
@@ -328,7 +328,7 @@ polygon:
328
328
329
329
The search returns the following document:
330
330
331
- .. code-block:: json
331
+ .. code-block:: text
332
332
333
333
{ "_id" : 1, "make" : "Fender", "description" : "Classic guitars known for their versatility.", "establishedYear" : 1946, "in_stock" : true, "in_stock_location" : { "type" : "Point", "coordinates" : ["-73.93615", "40.69791"] }, "rating" : 9 }
334
334
@@ -352,7 +352,7 @@ The following example searches the ``guitars`` collection for documents that hav
352
352
353
353
The search returns the following documents:
354
354
355
- .. code-block:: json
355
+ .. code-block:: text
356
356
357
357
{ "_id": 1, "make": "Fender", "description": "...", "establishedYear": 1946, "in_stock": true, "rating": 9 }
358
358
{ "_id": 2, "make": "Gibson", "description": "...", "establishedYear": 1902, "in_stock": true, "rating": 8 }
@@ -375,7 +375,7 @@ quality."
375
375
376
376
The search returns the following documents:
377
377
378
- .. code-block:: json
378
+ .. code-block:: text
379
379
380
380
{ "_id" : 3, "make" : "PRS", "description" : "High-end guitars known for their quality.", "establishedYear" : 1985, "in_stock" : true, "rating" : 9 }
381
381
{ "_id" : 4, "make" : "Kiesel", "description" : "Quality guitars made only for custom orders.", "establishedYear" : 2015, "in_stock" : false, "rating" : null }
@@ -406,7 +406,7 @@ order based on how close the value is to the number ``9``.
406
406
407
407
The search returns the following documents:
408
408
409
- .. code-block:: json
409
+ .. code-block:: text
410
410
411
411
{ "_id" : 1, "make" : "Fender", "description" : "...", "establishedYear" : 1946, "in_stock" : true, "rating" : 9 }
412
412
{ "_id" : 3, "make" : "PRS", "description" : "...", "establishedYear" : 1985, "in_stock" : true, "rating" : 9 }
@@ -434,7 +434,7 @@ the ``description`` field contains the phrase "classic guitars."
434
434
435
435
The search returns the following documents:
436
436
437
- .. code-block:: json
437
+ .. code-block:: text
438
438
439
439
{ "_id" : 1, "make" : "Fender", "description" : "Classic guitars known for their versatility.", "establishedYear" : 1946, "in_stock" : true, "rating" : 9 }
440
440
{ "_id" : 2, "make" : "Gibson", "description" : "Classic guitars known for their rich, full tones.", "establishedYear" : 1902, "in_stock" : true, "rating" : 8 }
@@ -450,7 +450,7 @@ phrases as follows:
450
450
451
451
This search returns the following documents:
452
452
453
- .. code-block:: json
453
+ .. code-block:: text
454
454
455
455
{ "_id" : 1, "make" : "Fender", "description" : "Classic guitars known for their versatility.", "establishedYear" : 1946, "in_stock" : true, "rating" : 9 }
456
456
{ "_id" : 4, "make" : "Kiesel", "description" : "Quality guitars made only for custom orders.", "establishedYear" : 2015, "in_stock" : false, "rating" : null }
@@ -484,7 +484,7 @@ the value of the ``description`` field matches each of the following criteria:
484
484
485
485
The search returns the following documents:
486
486
487
- .. code-block:: json
487
+ .. code-block:: text
488
488
489
489
{ "_id" : 1, "make" : "Fender", "description" : "Classic guitars known for their versatility.", "establishedYear" : 1946, "in_stock" : true, "rating" : 9 }
490
490
{ "_id" : 3, "make" : "PRS", "description" : "High-end guitars known for their quality.", "establishedYear" : 1985, "in_stock" : true, "rating" : 9 }
@@ -497,7 +497,7 @@ Range
497
497
~~~~~
498
498
499
499
Use the ``Range()`` method to search for documents in which the value of a
500
- specified field falls within a given numeric or date range.
500
+ specified field falls within a given numeric, date, or string range.
501
501
502
502
The following example searches the ``guitars`` collection for all documents with
503
503
an ``establishedYear`` value greater than 1980 and less than 2020.
@@ -510,12 +510,38 @@ an ``establishedYear`` value greater than 1980 and less than 2020.
510
510
511
511
The search returns the following results:
512
512
513
- .. code-block:: json
513
+ .. code-block:: text
514
514
515
515
{ "_id" : 3, "make" : "PRS", "description" : "High-end guitars known for their quality.", "establishedYear" : 1985, "in_stock" : true, "rating" : 9 }
516
516
{ "_id" : 4, "make" : "Kiesel", "description" : "Quality guitars made only for custom orders.", "establishedYear" : 2015, "in_stock" : false, "rating" : null }
517
517
{ "_id" : 6, "make" : "Strandberg", "description" : "Modern guitars known for their headless models.", "establishedYear" : 1982, "in_stock" : false, "rating" : null }
518
518
519
+ To search for documents in which the value of a specified field is within a
520
+ range of strings, you must first create a :atlas:`token index
521
+ </atlas-search/field-types/token-type/>` on the field. After you create the
522
+ index, you can search for documents based on a range of strings as shown in the
523
+ following example:
524
+
525
+ .. literalinclude:: /includes/fundamentals/code-examples/atlas-search/AtlasSearchExamples.cs
526
+ :start-after: // start-range-string
527
+ :end-before: // end-range-string
528
+ :language: csharp
529
+ :dedent:
530
+
531
+ The preceding example searches for any documents in which the string value of the
532
+ ``make`` field is greater than or equal to ``"Fender"`` and less than or equal
533
+ to ``"Kiesel"``. The driver compares the string values in :wikipedia:`lexicographic order
534
+ <Lexicographic_order>`.
535
+
536
+ The search returns the following results:
537
+
538
+ .. code-block:: text
539
+
540
+ { "_id" : 1, "make" : "Fender", "description" : "Classic guitars known for their versatility.", "establishedYear" : 1946, "in_stock" : true, "rating" : 9 }
541
+ { "_id" : 2, "make" : "Gibson", "description" : "Classic guitars known for their rich, full tones.", "establishedYear" : 1902, "in_stock" : true, "rating" : 8 }
542
+ { "_id" : 4, "make" : "Kiesel", "description" : "Quality guitars made only for custom orders.", "establishedYear" : 2015, "in_stock" : false, "rating" : null }
543
+ { "_id" : 5, "make" : "Ibanez", "description" : "Well-crafted guitars used by many professional guitarists.", "establishedYear" : 1957, "in_stock" : true, "rating" : 7 }
544
+
519
545
To learn more about the ``range`` operator, see the :atlas:`range </atlas-search/range>`
520
546
Atlas guide.
521
547
@@ -535,7 +561,7 @@ the value of the ``make`` field contains exactly six letters.
535
561
536
562
The search returns the following results:
537
563
538
- .. code-block:: json
564
+ .. code-block:: text
539
565
540
566
{ "_id" : 1, "make" : "Fender", "description" : "Classic guitars known for their versatility.", "establishedYear" : 1946, "in_stock" : true, "rating" : 9 }
541
567
{ "_id" : 2, "make" : "Gibson", "description" : "Classic guitars known for their rich, full tones.", "establishedYear" : 1902, "in_stock" : true, "rating" : 8 }
@@ -585,7 +611,7 @@ the value of the ``description`` field contains the strings "guitars" and
585
611
586
612
The search returns the following document:
587
613
588
- .. code-block:: json
614
+ .. code-block:: text
589
615
590
616
{ "_id" : 4, "make" : "Kiesel", "description" : "Quality guitars made only for custom orders.", "establishedYear" : 2015, "in_stock" : false, "rating" : null }
591
617
@@ -615,7 +641,7 @@ professionals".
615
641
616
642
The search returns the following document:
617
643
618
- .. code-block:: json
644
+ .. code-block:: text
619
645
620
646
{ "_id" : 5, "make" : "Ibanez", "description" : "Well-crafted guitars used by many professional guitarists.", "establishedYear" : 1957, "in_stock" : true, "rating" : 7 }
621
647
@@ -661,7 +687,7 @@ field contains the string "Strand" followed by any other characters.
661
687
662
688
The search returns the following document:
663
689
664
- .. code-block:: json
690
+ .. code-block:: text
665
691
666
692
{ "_id" : 6, "make" : "Strandberg", "description" : "Modern guitars known for their headless models.", "establishedYear" : 1982, "in_stock" : false, "rating" : null }
667
693
0 commit comments