Skip to content

Commit

Permalink
Merge pull request foursquare#54 from holdenk/master
Browse files Browse the repository at this point in the history
Source based on 0.15.1
  • Loading branch information
adamalix committed Aug 21, 2012
2 parents 7ac8fd2 + a817fc5 commit 8657395
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "slashem"

version := "0.14.3"
version := "0.15.2"

organization := "com.foursquare"

Expand Down Expand Up @@ -131,4 +131,4 @@ ivyXML := (
<exclude module="jmxtools"/>
<exclude module="jmxri"/>
</dependencies>
)
)
11 changes: 7 additions & 4 deletions src/main/scala/com/foursquare/slashem/Schema.scala
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,9 @@ trait ElasticSchema[M <: Record[M]] extends SlashemSchema[M] {
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
//If a score is 0.0 this will blow up :(
val scoreDouble = doc.score().toDouble
val annotedMap = (m.asScala ++ List("score" -> scoreDouble)).toMap
val hlf = doc.getHighlightFields()
if (hlf == null) {
Pair(annotedMap,None)
Expand Down Expand Up @@ -747,11 +749,12 @@ trait ElasticSchema[M <: Record[M]] extends SlashemSchema[M] {
def scoreFields(query: ElasticQueryBuilder, fieldsToScore: List[ScoreBoost]): ElasticQueryBuilder = {
val scoredFields = fieldsToScore.map(_.elasticBoost)
val params = scoredFields.flatMap(_._1)
val scriptSrc = scoredFields.map(_._2).mkString(" + ")
val scriptSrc = scoredFields.map(_._2).mkString(" * ")
val paramNames = (1 to params.length).map("p"+_)
val script = scriptSrc.format(paramNames:_*)
val namesAndParams = paramNames.zip(params).toMap
val scoreScript = "_score * (1 +"+ script + " )"
//The ES client library breaks badly with low score values
val scoreScript = "1.0 + _score * "+ script + ""
scoreWithScript(query, scoreScript, namesAndParams, false)
}

Expand Down Expand Up @@ -1434,7 +1437,7 @@ class PointField[T <: Record[T]](override val owner: T) extends Field[Pair[Doubl
try {
a match {
case "" => Empty
/*
/*
* GeoJSON has (long, lat) instead of (lat, long)
* Only ES uses GeoJSON spec and returns an ArrayList
*
Expand Down

0 comments on commit 8657395

Please sign in to comment.