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:
77
77
text(" description" )
78
78
```
79
79
80
+ This example specifies a text index key for every field that contains string data:
81
+
82
+ ``` java
83
+ text()
84
+ ```
85
+
80
86
### Hashed Index
81
87
82
88
To 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) {
158
158
return new BsonDocument (fieldName , new BsonString ("text" ));
159
159
}
160
160
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
+
161
171
/**
162
172
* Create an index key for a hashed index on the given field.
163
173
*
Original file line number Diff line number Diff line change @@ -114,6 +114,14 @@ class IndexesFunctionalSpecification extends OperationFunctionalSpecification {
114
114
getCollectionHelper(). listIndexes()* . get(' key' ). contains(parse(' {_fts: "text", _ftsx: 1}' ))
115
115
}
116
116
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
+
117
125
def ' hashed' () {
118
126
when :
119
127
getCollectionHelper(). createIndex(hashed(' x' ))
Original file line number Diff line number Diff line change @@ -69,7 +69,8 @@ class IndexesSpecification extends Specification {
69
69
70
70
def ' text' () {
71
71
expect :
72
- toBson(text(' x' ,)) == parse(' {x : "text"}' )
72
+ toBson(text(' x' )) == parse(' {x : "text"}' )
73
+ toBson(text()) == parse(' { "$**" : "text"}' )
73
74
}
74
75
75
76
def ' hashed' () {
You can’t perform that action at this time.
0 commit comments