@@ -21,11 +21,10 @@ import com.mongodb.MongoQueryException
2121import com.mongodb.OperationFunctionalSpecification
2222import org.bson.Document
2323import org.bson.conversions.Bson
24- import spock.lang.IgnoreIf
2524
26- import static com.mongodb.ClusterFixture.serverVersionGreaterThan
2725import static com.mongodb.client.model.Filters.and
2826import static com.mongodb.client.model.Filters.eq
27+ import static com.mongodb.client.model.Filters.text
2928import static com.mongodb.client.model.Projections.elemMatch
3029import static com.mongodb.client.model.Projections.exclude
3130import static com.mongodb.client.model.Projections.excludeId
@@ -35,21 +34,21 @@ import static com.mongodb.client.model.Projections.metaTextScore
3534import static com.mongodb.client.model.Projections.slice
3635
3736class 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 ),
3938 new Document (' a' , 2 ). append(' b' , 3 ),
4039 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 ),
4342 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 ' )
4544 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 ),
4746 new Document (' a' , 2 ). append(' b' , 3 ),
4847 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 ),
5049 new Document (' a' , 2 ). append(' b' , 3 ),
5150 new Document (' a' , 3 ). append(' b' , 4 )])
52- .append(' score' , 0 .0 )
51+ .append(' score' , 1 .0 )
5352
5453 def setup () {
5554 getCollectionHelper(). insertDocuments(a)
@@ -99,13 +98,12 @@ class ProjectionFunctionalSpecification extends OperationFunctionalSpecification
9998 find(slice(' y' , 1 , 2 )) == [aYSlice12]
10099 }
101100
102- @IgnoreIf ({ serverVersionGreaterThan(' 4.2' ) })
103101 def ' metaTextScore' () {
104102 given :
105- getCollectionHelper(). createIndex(new Document (' y ' , ' text' ))
103+ getCollectionHelper(). createIndex(new Document (' x ' , ' text' ))
106104
107105 expect :
108- find(metaTextScore(' score' )) == [aWithScore]
106+ find(text( ' coffee ' ), metaTextScore(' score' )) == [aWithScore]
109107 }
110108
111109 def ' combine fields' () {
0 commit comments