Skip to content
Browse files

Merge pull request #23 from foursquare/es-search-type-test

Es search type
  • Loading branch information...
2 parents 50f6291 + 241425f commit 94d2fbdaf2ad92a94474685add6b5affce7a1853 @adamalix adamalix committed Apr 10, 2012
View
5 src/main/scala/com/foursquare/slashem/Schema.scala
@@ -476,7 +476,7 @@ trait ElasticSchema[M <: Record[M]] extends SlashemSchema[M] {
.setQuery(query)
.setFrom(from)
.setSize(limit)
- .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
+ .setSearchType(SearchType.QUERY_THEN_FETCH)
val request = qb.sort match {
case None => baseRequest
//Handle sorting by fields quickly
@@ -530,7 +530,8 @@ trait ElasticSchema[M <: Record[M]] extends SlashemSchema[M] {
response: SearchResponse): SearchResults[M, Y] = {
val time = response.tookInMillis()
val hitCount = response.getHits().totalHits().toInt
- val docs: Array[(Map[String,Any], Option[Map[String,java.util.ArrayList[String]]])] = response.getHits().getHits().map(doc => {
+ val esHits = response.getHits().getHits()
+ val docs: Array[(Map[String,Any], Option[Map[String,java.util.ArrayList[String]]])] = esHits.map(doc => {
val m = doc.sourceAsMap()
val annotedMap = (m.asScala ++ List("score" -> doc.score().toDouble)).toMap
val hlf = doc.getHighlightFields()
View
7 src/test/scala/com/foursquare/slashem/ElasticQueryTest.scala
@@ -205,11 +205,14 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
val doc1b = rWithLowPhraseBoost.response.results.apply(2)
val doc2b = rWithHighPhraseBoost.response.results.apply(2)
val doc3b = rNoPhraseBoost.response.results.apply(2)
- val lastResult = List(doc1b,doc2b,doc3b)
- lastResult.map(doc => Assert.assertEquals(new ObjectId("4c809f4251ada1cdc3790b13"), doc.id.is))
//Make sure the scores are actually impacted by the phraseBoost
Assert.assertTrue(doc1b.score.value > doc2b.score.value)
Assert.assertTrue(doc3b.score.value > doc1b.score.value)
+ val lastResult = List(rWithLowPhraseBoost.response.results.apply(3),
+ rWithHighPhraseBoost.response.results.apply(3),
+ rNoPhraseBoost.response.results.apply(3)
+ )
+ lastResult.map(doc => Assert.assertEquals(new ObjectId("4c809f4251ada1cdc3790b18"), doc.id.is))
}
@Test
def testFieldFaceting {

0 comments on commit 94d2fbd

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