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.
@@ -21,11 +21,10 @@ import com.mongodb.MongoQueryException
import com.mongodb.OperationFunctionalSpecification
import org.bson.Document
import org.bson.conversions.Bson
-import spock.lang.IgnoreIf
-import static com.mongodb.ClusterFixture.serverVersionGreaterThan
import static com.mongodb.client.model.Filters.and
import static com.mongodb.client.model.Filters.eq
+import static com.mongodb.client.model.Filters.text
import static com.mongodb.client.model.Projections.elemMatch
import static com.mongodb.client.model.Projections.exclude
import static com.mongodb.client.model.Projections.excludeId
@@ -35,21 +34,21 @@ import static com.mongodb.client.model.Projections.metaTextScore
import static com.mongodb.client.model.Projections.slice
class ProjectionFunctionalSpecification extends OperationFunctionalSpecification {
- def a = new Document('_id', 1).append('x', 1).append('y', [new Document('a', 1).append('b', 2),
+ def a = new Document('_id', 1).append('x', 'coffee').append('y', [new Document('a', 1).append('b', 2),
new Document('a', 2).append('b', 3),
new Document('a', 3).append('b', 4)])
- def aYSlice1 = new Document('_id', 1).append('x', 1).append('y', [new Document('a', 1).append('b', 2)])
- def aYSlice12 = new Document('_id', 1).append('x', 1).append('y', [new Document('a', 2).append('b', 3),
+ def aYSlice1 = new Document('_id', 1).append('x', 'coffee').append('y', [new Document('a', 1).append('b', 2)])
+ def aYSlice12 = new Document('_id', 1).append('x', 'coffee').append('y', [new Document('a', 2).append('b', 3),
new Document('a', 3).append('b', 4)])
- def aNoY = new Document('_id', 1).append('x', 1)
+ def aNoY = new Document('_id', 1).append('x', 'coffee')
def aId = new Document('_id', 1)
- def aNoId = new Document().append('x', 1).append('y', [new Document('a', 1).append('b', 2),
+ def aNoId = new Document().append('x', 'coffee').append('y', [new Document('a', 1).append('b', 2),
new Document('a', 2).append('b', 3),
new Document('a', 3).append('b', 4)])
- def aWithScore = new Document('_id', 1).append('x', 1).append('y', [new Document('a', 1).append('b', 2),
+ def aWithScore = new Document('_id', 1).append('x', 'coffee').append('y', [new Document('a', 1).append('b', 2),
new Document('a', 2).append('b', 3),
new Document('a', 3).append('b', 4)])
- .append('score', 0.0)
+ .append('score', 1.0)
def setup() {
getCollectionHelper().insertDocuments(a)
@@ -99,13 +98,12 @@ class ProjectionFunctionalSpecification extends OperationFunctionalSpecification
find(slice('y', 1, 2)) == [aYSlice12]
}
- @IgnoreIf({ serverVersionGreaterThan('4.2') })
def 'metaTextScore'() {
given:
- getCollectionHelper().createIndex(new Document('y', 'text'))
+ getCollectionHelper().createIndex(new Document('x', 'text'))
expect:
- find(metaTextScore('score')) == [aWithScore]
+ find(text('coffee'), metaTextScore('score')) == [aWithScore]
}
def 'combine fields'() {
