@@ -21,11 +21,10 @@ import com.mongodb.MongoQueryException
21
21
import com.mongodb.OperationFunctionalSpecification
22
22
import org.bson.Document
23
23
import org.bson.conversions.Bson
24
- import spock.lang.IgnoreIf
25
24
26
- import static com.mongodb.ClusterFixture.serverVersionGreaterThan
27
25
import static com.mongodb.client.model.Filters.and
28
26
import static com.mongodb.client.model.Filters.eq
27
+ import static com.mongodb.client.model.Filters.text
29
28
import static com.mongodb.client.model.Projections.elemMatch
30
29
import static com.mongodb.client.model.Projections.exclude
31
30
import static com.mongodb.client.model.Projections.excludeId
@@ -35,21 +34,21 @@ import static com.mongodb.client.model.Projections.metaTextScore
35
34
import static com.mongodb.client.model.Projections.slice
36
35
37
36
class ProjectionFunctionalSpecification extends OperationFunctionalSpecification {
38
- def a = new Document (' _id' , 1 ). append(' x' , 1 ). append(' y' , [new Document (' a' , 1 ). append(' b' , 2 ),
37
+ def a = new Document (' _id' , 1 ). append(' x' , ' coffee ' ). append(' y' , [new Document (' a' , 1 ). append(' b' , 2 ),
39
38
new Document (' a' , 2 ). append(' b' , 3 ),
40
39
new Document (' a' , 3 ). append(' b' , 4 )])
41
- def aYSlice1 = new Document (' _id' , 1 ). append(' x' , 1 ). append(' y' , [new Document (' a' , 1 ). append(' b' , 2 )])
42
- def aYSlice12 = new Document (' _id' , 1 ). append(' x' , 1 ). append(' y' , [new Document (' a' , 2 ). append(' b' , 3 ),
40
+ def aYSlice1 = new Document (' _id' , 1 ). append(' x' , ' coffee ' ). append(' y' , [new Document (' a' , 1 ). append(' b' , 2 )])
41
+ def aYSlice12 = new Document (' _id' , 1 ). append(' x' , ' coffee ' ). append(' y' , [new Document (' a' , 2 ). append(' b' , 3 ),
43
42
new Document (' a' , 3 ). append(' b' , 4 )])
44
- def aNoY = new Document (' _id' , 1 ). append(' x' , 1 )
43
+ def aNoY = new Document (' _id' , 1 ). append(' x' , ' coffee ' )
45
44
def aId = new Document (' _id' , 1 )
46
- def aNoId = new Document (). append(' x' , 1 ). append(' y' , [new Document (' a' , 1 ). append(' b' , 2 ),
45
+ def aNoId = new Document (). append(' x' , ' coffee ' ). append(' y' , [new Document (' a' , 1 ). append(' b' , 2 ),
47
46
new Document (' a' , 2 ). append(' b' , 3 ),
48
47
new Document (' a' , 3 ). append(' b' , 4 )])
49
- def aWithScore = new Document (' _id' , 1 ). append(' x' , 1 ). append(' y' , [new Document (' a' , 1 ). append(' b' , 2 ),
48
+ def aWithScore = new Document (' _id' , 1 ). append(' x' , ' coffee ' ). append(' y' , [new Document (' a' , 1 ). append(' b' , 2 ),
50
49
new Document (' a' , 2 ). append(' b' , 3 ),
51
50
new Document (' a' , 3 ). append(' b' , 4 )])
52
- .append(' score' , 0 .0 )
51
+ .append(' score' , 1 .0 )
53
52
54
53
def setup () {
55
54
getCollectionHelper(). insertDocuments(a)
@@ -99,13 +98,12 @@ class ProjectionFunctionalSpecification extends OperationFunctionalSpecification
99
98
find(slice(' y' , 1 , 2 )) == [aYSlice12]
100
99
}
101
100
102
- @IgnoreIf ({ serverVersionGreaterThan(' 4.2' ) })
103
101
def ' metaTextScore' () {
104
102
given :
105
- getCollectionHelper(). createIndex(new Document (' y ' , ' text' ))
103
+ getCollectionHelper(). createIndex(new Document (' x ' , ' text' ))
106
104
107
105
expect :
108
- find(metaTextScore(' score' )) == [aWithScore]
106
+ find(text( ' coffee ' ), metaTextScore(' score' )) == [aWithScore]
109
107
}
110
108
111
109
def ' combine fields' () {
0 commit comments