Skip to content

Commit f567f93

Browse files
committed
Re-enable metaTextScore functional test
Change the test so that it produces a non-zero score so that the score won't be excluded by later server versions. JAVA-3465
1 parent 4072f30 commit f567f93

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

driver-core/src/test/functional/com/mongodb/client/model/ProjectionFunctionalSpecification.groovy

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ import com.mongodb.MongoQueryException
2121
import com.mongodb.OperationFunctionalSpecification
2222
import org.bson.Document
2323
import org.bson.conversions.Bson
24-
import spock.lang.IgnoreIf
2524

26-
import static com.mongodb.ClusterFixture.serverVersionGreaterThan
2725
import static com.mongodb.client.model.Filters.and
2826
import static com.mongodb.client.model.Filters.eq
27+
import static com.mongodb.client.model.Filters.text
2928
import static com.mongodb.client.model.Projections.elemMatch
3029
import static com.mongodb.client.model.Projections.exclude
3130
import static com.mongodb.client.model.Projections.excludeId
@@ -35,21 +34,21 @@ import static com.mongodb.client.model.Projections.metaTextScore
3534
import static com.mongodb.client.model.Projections.slice
3635

3736
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),
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

Comments
 (0)