File tree Expand file tree Collapse file tree 4 files changed +26
-1
lines changed
docs/reference/content/builders
main/com/mongodb/client/model
functional/com/mongodb/client/model
unit/com/mongodb/client/model Expand file tree Collapse file tree 4 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,12 @@ This example specifies a text index key for the `description` field:
7777text(" description" )
7878```
7979
80+ This example specifies a text index key for every field that contains string data:
81+
82+ ``` java
83+ text()
84+ ```
85+
8086### Hashed Index
8187
8288To specify a [ hashed] ({{< docsref "core/index-hashed" >}}) index key, use the ` hashed ` method.
Original file line number Diff line number Diff line change @@ -158,6 +158,16 @@ public static Bson text(final String fieldName) {
158158 return new BsonDocument (fieldName , new BsonString ("text" ));
159159 }
160160
161+ /**
162+ * Create an index key for a text index on every field that contains string data.
163+ *
164+ * @return the index specification
165+ * @mongodb.driver.manual core/text text index
166+ */
167+ public static Bson text () {
168+ return text ("$**" );
169+ }
170+
161171 /**
162172 * Create an index key for a hashed index on the given field.
163173 *
Original file line number Diff line number Diff line change @@ -114,6 +114,14 @@ class IndexesFunctionalSpecification extends OperationFunctionalSpecification {
114114 getCollectionHelper(). listIndexes()* . get(' key' ). contains(parse(' {_fts: "text", _ftsx: 1}' ))
115115 }
116116
117+ def ' text wildcard' () {
118+ when :
119+ getCollectionHelper(). createIndex(text())
120+
121+ then :
122+ getCollectionHelper(). listIndexes()* . get(' key' ). contains(parse(' {_fts: "text", _ftsx: 1}' ))
123+ }
124+
117125 def ' hashed' () {
118126 when :
119127 getCollectionHelper(). createIndex(hashed(' x' ))
Original file line number Diff line number Diff line change @@ -69,7 +69,8 @@ class IndexesSpecification extends Specification {
6969
7070 def ' text' () {
7171 expect :
72- toBson(text(' x' ,)) == parse(' {x : "text"}' )
72+ toBson(text(' x' )) == parse(' {x : "text"}' )
73+ toBson(text()) == parse(' { "$**" : "text"}' )
7374 }
7475
7576 def ' hashed' () {
You can’t perform that action at this time.
0 commit comments