Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix boost query behaviour

  • Loading branch information...
commit 95f57307b7859a8d7e7a087e75f0629ac5636b26 1 parent 7ec8e3d
@holdenk holdenk authored
View
8 src/main/scala/com/foursquare/slashem/Schema.scala
@@ -719,14 +719,14 @@ trait ElasticSchema[M <: Record[M]] extends SlashemSchema[M] {
boostedQuery.negativeBoost(0.1.toFloat)
boostedQuery
} else {
- val orQuery = EQueryBuilders.boolQuery
- orQuery.should(query)
- boostQueries.map(q => orQuery.should(q.elasticExtend(qb.queryFields,
+ val boolQuery = EQueryBuilders.boolQuery
+ boolQuery.must(query)
+ boostQueries.map(q => boolQuery.should(q.elasticExtend(qb.queryFields,
qb.phraseBoostFields,
qb.minimumMatch)
)
)
- orQuery
+ boolQuery
}
}
View
9 src/test/scala/com/foursquare/slashem/ElasticQueryTest.scala
@@ -286,6 +286,15 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
val r = ESimplePanda where (_.name contains "loler") and (x => (x.hobos contains "nyet") or (x.hobos contains "robot")) fetch()
Assert.assertEquals(r.response.results.length,2)
}
+
+ @Test
+ def testBoosting {
+ val r = (ESimplePanda where (_.name contains "DOESNOTEXISTDONOTADTHISTOKENloler")
+ boostQuery(_.name contains("loler", 10)) fetch())
+ Assert.assertEquals(r.response.results.length,0)
+ }
+
+
@Test
def testPhraseBoostOrdering {
val rWithLowPhraseBoost = ESimplePanda where (_.name contains "loler skates") phraseBoost(_.name,10) fetch()
Please sign in to comment.
Something went wrong with that request. Please try again.