Skip to content
Browse files

Merge pull request #49 from holdenk/master

Fix boost queries with ES
  • Loading branch information...
2 parents 7ec8e3d + f64c228 commit fd69099b84c66fed5345752b1105881d899701df @holdenk holdenk committed Jul 18, 2012
View
2 build.sbt
@@ -1,6 +1,6 @@
name := "slashem"
-version := "0.13.2"
+version := "0.14.0"
organization := "com.foursquare"
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()

0 comments on commit fd69099

Please sign in to comment.
Something went wrong with that request. Please try again.