Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed Terms queries and filters.

  • Loading branch information...
commit 75d6c4ffc719e1fda415483714a4728ad2216cda 1 parent a1ac4bc
Adam Alix adamalix authored
10 src/main/scala/com/foursquare/slashem/Ast.scala
View
@@ -430,7 +430,10 @@ object Ast {
val weight = qf.head.weight.toFloat
query match {
case term::Nil => EQueryBuilders.termQuery(fieldName, term).boost(weight)
- case terms => EQueryBuilders.termsQuery(fieldName, terms.asJava).boost(weight)
+ case terms => {
+ val moarTerms = terms.toSeq.map(_.toString)
+ EQueryBuilders.termsQuery(fieldName, moarTerms: _*).boost(weight)
+ }
}
}
/** @inheritdoc */
@@ -438,7 +441,10 @@ object Ast {
val fieldName = qf.head.fieldName
query match {
case term::Nil => EFilterBuilders.termFilter(fieldName, term).cache(cached)
- case terms => EFilterBuilders.termsFilter(fieldName, terms.asJava).cache(cached)
+ case terms => {
+ val moarTerms = terms.toSeq.map(_.toString)
+ EFilterBuilders.termsFilter(fieldName, moarTerms: _*).cache(cached)
+ }
}
}
}
26 src/test/scala/com/foursquare/slashem/ElasticQueryTest.scala
View
@@ -310,17 +310,6 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
}
@Test
- def testUnanalyzed {
- try {
- val res1 = ESimplePanda where (_.termsfield eqs "termhit") fetch()
- //val res2 = ESimplePanda where (_.termsfield in List("randomterm", "termhit")) fetch()
- Assert.assertEquals(res1.response.results.length, 1)
- } catch {
- case e: Exception => e.printStackTrace()
- }
- }
-
- @Test
def testListFieldIn {
val response1 = ESimplePanda where (_.favnums in List(2, 3, 4, 5)) fetch()
val response2 = ESimplePanda where (_.favnums in List(99)) fetch()
@@ -357,6 +346,21 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
Assert.assertEquals(ids2.intersect(idsWithFavNums).length, 3)
}
+ @Test
+ def testUnanalyzed {
+ try {
+ val res1 = ESimplePanda where (_.termsfield eqs "termhit") fetch()
+ val res2 = ESimplePanda where (_.termsfield in List("randomterm", "termhit")) fetch()
+ Assert.assertEquals(res1.response.results.length, 1)
+ Assert.assertEquals(res2.response.results.length, 1)
+ } catch {
+ case e: Exception => {
+ e.printStackTrace()
+ Assert.fail
+ }
+ }
+ }
+
@Before
def hoboPrepIndex() {
ESimplePanda.meta.node = ElasticNode.node
Please sign in to comment.
Something went wrong with that request. Please try again.