Skip to content
Browse files

Merge pull request #40 from foursquare/custom-scoring

Custom scoring support
  • Loading branch information...
2 parents 3bc3b48 + 38290e9 commit 95c71e7b32f86d23e0a7f8f7f607aba02aa16de5 @holdenk holdenk committed Jun 1, 2012
View
180 src/main/scala/com/foursquare/slashem/QueryBuilder.scala
@@ -31,10 +31,16 @@ abstract sealed class StrictQualityFilter extends QualityFilter
trait FacetCount
abstract sealed class MinimumFacetCount extends FacetCount
abstract sealed class NoMinimumFacetCount extends FacetCount
+//We need to make sure that we can generate the correct score script
+//for ES
+trait ScoreType
+abstract sealed class NoScoreModifiers extends ScoreType
+abstract sealed class ScoreScript extends ScoreType
+abstract sealed class NativeScoreScript extends ScoreType
case class FacetSettings(facetFieldList: List[Field], facetMinCount: Option[Int], facetLimit: Option[Int])
-case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <: Highlighting, Q <: QualityFilter, MinFacetCount <: FacetCount, FacetLimit](
+case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <: Highlighting, Q <: QualityFilter, MinFacetCount <: FacetCount, FacetLimit, ST <: ScoreType](
meta: M with SlashemSchema[M],
clauses: AbstractClause, // Like AndCondition in MongoHelpers
filters: List[AbstractClause],
@@ -50,6 +56,7 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
queryType: Option[String],
fieldsToFetch: List[String],
facetSettings: FacetSettings,
+ customScoreScript: Option[(String, Map[String, Any])],
hls: Option[String],
hlFragSize: Option[Int],
creator: Option[(Pair[Map[String,Any],
@@ -62,14 +69,14 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
val DefaultStart = 0
import Helpers._
- def and(c: M => AbstractClause): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] = {
+ def and(c: M => AbstractClause): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] = {
clauses match{
case AndClause(elements) => this.copy(meta=meta,clauses=AndClause(c(meta)::elements))
case _ => this.copy(meta=meta,clauses=AndClause(List(c(meta),clauses)))
}
}
- def or(c: M => AbstractClause): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] = {
+ def or(c: M => AbstractClause): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] = {
clauses match{
case OrClause(elements) => this.copy(meta=meta,clauses=OrClause(c(meta)::elements))
case _ => this.copy(meta=meta,clauses=OrClause(List(c(meta),clauses)))
@@ -81,18 +88,18 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
*have a separate cache. Filter queries are great for queries that are repeated often which
*you want to constrain your result set by.
* @param f The query to filter on */
- def filter[F](f: M => Clause[F]): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] = {
+ def filter[F](f: M => Clause[F]): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] = {
this.copy(filters=f(meta)::filters)
}
- def orFilter[F](f: M => Clause[F]): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] = {
+ def orFilter[F](f: M => Clause[F]): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] = {
filters match {
case Nil => this.copy(filters=f(meta)::filters)
case x::xs => this.copy(filters=OrClause(List(f(meta),x))::xs)
}
}
/** Add a comment */
- def addComment(s: String): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] = {
+ def addComment(s: String): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] = {
comment match {
case None => this.copy(comment=Some(s))
case Some(a) => this.copy(comment=Some(s + a))
@@ -103,7 +110,7 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
/** A boostQuery affects the scoring of the results.
@param f The boost query
*/
- def boostQuery[F](f: M => Clause[F]): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] = {
+ def boostQuery[F](f: M => Clause[F]): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] = {
this.copy(boostQueries=f(meta) :: boostQueries)
}
@@ -131,7 +138,7 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
/** Select into a case class */
- def selectCase [F1, CC](f: M => SlashemField[F1, M], create: Option[F1] => CC)(implicit ev: (Y,H) =:= (NoSelect,NoHighlighting)): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, CC](f: M => SlashemField[F1, M], create: Option[F1] => CC)(implicit ev: (Y,H) =:= (NoSelect,NoHighlighting)): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Name: String = f(meta).name
val f1Field: SlashemField[F1, M] = f(meta)
val transformer = Some(((doc: Pair[Map[String,Any],Option[Map[String,ArrayList[String]]]]) => {
@@ -140,10 +147,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
QueryBuilder(meta, clauses, filters, boostQueries, queryFields,
phraseBoostFields, boostFields, start, limit, tieBreaker,
sort, minimumMatch, queryType, (f1Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, CC](f: M => SlashemField[F1, M], create: (Option[F1], List[String]) => CC)(implicit ev: (Y,H) =:= (NoSelect,YesHighlighting)): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, CC](f: M => SlashemField[F1, M], create: (Option[F1], List[String]) => CC)(implicit ev: (Y,H) =:= (NoSelect,YesHighlighting)): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Name: String = f(meta).name
val f1Field: SlashemField[F1, M] = f(meta)
val transformer = Some(((doc: Pair[Map[String,Any],Option[Map[String,ArrayList[String]]]]) => {
@@ -153,44 +160,47 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
QueryBuilder(meta, clauses, filters, boostQueries, queryFields,
phraseBoostFields, boostFields, start, limit, tieBreaker,
sort, minimumMatch, queryType, (f1Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Where you want to start fetching results back from
* @param s Where you want to start fetching results from. */
- def start(s: Long): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] = {
+ def start(s: Long): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] = {
this.copy(start=Some(s))
}
+ // Implicits on the following functions guard against the function being
+ // multiple times
+
/** Limit the query to only fetch back l results.
* Can only be applied to a query without an existing limit
* @param l The limit */
- def limit(l: Int)(implicit ev: Lim =:= Unlimited): QueryBuilder[M, Ord, Limited, MM, Y, H, Q, MinFacetCount, FacetLimit] = {
+ def limit(l: Int)(implicit ev: Lim =:= Unlimited): QueryBuilder[M, Ord, Limited, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] = {
this.copy(limit=Some(l))
}
/** Turn on highlighting. Must be done prior to select case
*/
def highlighting()(implicit ev: (Y,H) =:= (NoSelect,NoHighlighting)):
- QueryBuilder[M, Ord, Lim, MM, Y, YesHighlighting, Q, MinFacetCount, FacetLimit] = {
+ QueryBuilder[M, Ord, Lim, MM, Y, YesHighlighting, Q, MinFacetCount, FacetLimit, ST] = {
this.copy(hls=Some("on"))
}
def highlighting(fragSize: Int)(implicit ev: (Y,H) =:= (NoSelect,NoHighlighting)):
- QueryBuilder[M, Ord, Lim, MM, Y, YesHighlighting, Q, MinFacetCount, FacetLimit] = {
+ QueryBuilder[M, Ord, Lim, MM, Y, YesHighlighting, Q, MinFacetCount, FacetLimit, ST] = {
this.copy(hls=Some("on"), hlFragSize = Some(fragSize))
}
/** Add a field based facet */
- def facetField[F](f: M => SlashemField[F,M]): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] = {
+ def facetField[F](f: M => SlashemField[F,M]): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] = {
this.copy(facetSettings=facetSettings.copy(facetFieldList=Field(f(meta).name)::facetSettings.facetFieldList))
}
/** Set a minimum facet match count
* Not supported with elastic search
*/
def minimumFacetCount(mfc: Int)(implicit ev: (MinFacetCount) =:= (NoMinimumFacetCount)):
- QueryBuilder[M, Ord, Lim, MM, Y, YesHighlighting, Q, MinimumFacetCount, FacetLimit] = {
+ QueryBuilder[M, Ord, Lim, MM, Y, YesHighlighting, Q, MinimumFacetCount, FacetLimit, ST] = {
this.copy(facetSettings=facetSettings.copy(facetMinCount=Some(mfc)))
}
@@ -200,20 +210,20 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
* In Solr defaults to 100
*/
def facetLimit(limit: Int)(implicit ev: FacetLimit =:= Unlimited):
- QueryBuilder[M, Ord, Lim, MM, Y, YesHighlighting, Q, MinFacetCount, Limited] = {
+ QueryBuilder[M, Ord, Lim, MM, Y, YesHighlighting, Q, MinFacetCount, Limited, ST] = {
this.copy(facetSettings=facetSettings.copy(facetLimit=Some(limit)))
}
/** Turn on quality filtering.
*/
- def qualityFilter(f: Double,m: Int)(implicit ev: Q =:= NoQualityFilter): QueryBuilder[M, Ord, Lim, MM, Y, H, StrictQualityFilter, MinFacetCount, FacetLimit] = {
+ def qualityFilter(f: Double,m: Int)(implicit ev: Q =:= NoQualityFilter): QueryBuilder[M, Ord, Lim, MM, Y, H, StrictQualityFilter, MinFacetCount, FacetLimit, ST] = {
this.copy(fallOf=Some(f),min=Some(m))
}
/** In edismax the score is max({scores})+tieBreak*\sum{scores}) */
- def tieBreaker(t: Double): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] = {
+ def tieBreaker(t: Double): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] = {
this.copy(tieBreaker=Some(t))
}
@@ -222,33 +232,33 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
/** Order the results by a specific field in ascending order.
* Can only be applied to an unordered query.
* @param f Field to order by */
- def orderAsc[F](f: M => SlashemField[F, M])(implicit ev: Ord =:= Unordered): QueryBuilder[M, Ordered, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] = {
+ def orderAsc[F](f: M => SlashemField[F, M])(implicit ev: Ord =:= Unordered): QueryBuilder[M, Ordered, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] = {
QueryBuilder(meta, clauses, filters, boostQueries, queryFields, phraseBoostFields,
boostFields, start, limit, tieBreaker,
sort=Some(Field(f(meta).name), "asc"), minimumMatch, queryType, fieldsToFetch,
- facetSettings, hls, hlFragSize, creator, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, creator, comment, fallOf, min)
}
/** Order the results by a specific field in descending order.
* Can only be applied to an unordered query.
* @param f Field to order by */
- def orderDesc[F](f: M => SlashemField[F, M])(implicit ev: Ord =:= Unordered): QueryBuilder[M, Ordered, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] = {
+ def orderDesc[F](f: M => SlashemField[F, M])(implicit ev: Ord =:= Unordered): QueryBuilder[M, Ordered, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] = {
QueryBuilder(meta, clauses, filters, boostQueries, queryFields, phraseBoostFields, boostFields,
start, limit, tieBreaker, sort=Some(Field(f(meta).name), "desc"),
- minimumMatch, queryType, fieldsToFetch, facetSettings, hls, hlFragSize, creator, comment, fallOf, min)
+ minimumMatch, queryType, fieldsToFetch, facetSettings, customScoreScript, hls, hlFragSize, creator, comment, fallOf, min)
}
/** Handle a more complex field sort */
- def complexOrderAsc(f: M => ScoreBoost)(implicit ev: Ord =:= Unordered): QueryBuilder[M, Ordered, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] = {
+ def complexOrderAsc(f: M => ScoreBoost)(implicit ev: Ord =:= Unordered): QueryBuilder[M, Ordered, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] = {
QueryBuilder(meta, clauses, filters, boostQueries, queryFields, phraseBoostFields, boostFields,
start, limit, tieBreaker, sort=Some(f(meta), "asc"),
- minimumMatch, queryType, fieldsToFetch, facetSettings, hls, hlFragSize, creator, comment, fallOf, min)
+ minimumMatch, queryType, fieldsToFetch, facetSettings, customScoreScript, hls, hlFragSize, creator, comment, fallOf, min)
}
/** Handle a more complex field sort */
- def complexOrderDesc(f: M => ScoreBoost)(implicit ev: Ord =:= Unordered): QueryBuilder[M, Ordered, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] = {
+ def complexOrderDesc(f: M => ScoreBoost)(implicit ev: Ord =:= Unordered): QueryBuilder[M, Ordered, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] = {
QueryBuilder(meta, clauses, filters, boostQueries, queryFields, phraseBoostFields, boostFields,
start, limit, tieBreaker, sort=Some(f(meta), "desc"),
- minimumMatch, queryType, fieldsToFetch, facetSettings, hls, hlFragSize, creator, comment, fallOf, min)
+ minimumMatch, queryType, fieldsToFetch, facetSettings, customScoreScript, hls, hlFragSize, creator, comment, fallOf, min)
}
@@ -258,7 +268,7 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
* terms to match.
* You can only use one of minimumMatchAbsolute or minimumMatchPercent.
* @param percent The minimum percent of tokens to match */
- def minimumMatchPercent(percent: Int)(implicit ev: MM =:= defaultMM): QueryBuilder[M, Ord, Lim, customMM, Y, H, Q, MinFacetCount, FacetLimit] = {
+ def minimumMatchPercent(percent: Int)(implicit ev: MM =:= defaultMM): QueryBuilder[M, Ord, Lim, customMM, Y, H, Q, MinFacetCount, FacetLimit, ST] = {
this.copy(minimumMatch=Some(percent.toString+"%"))
}
@@ -267,14 +277,14 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
* to match. Note: You must chose one or the other.
* @param count The minimum number of tokens to match
*/
- def minimumMatchAbsolute(count: Int)(implicit ev: MM =:= defaultMM): QueryBuilder[M, Ord, Lim, customMM, Y, H, Q, MinFacetCount, FacetLimit] = {
+ def minimumMatchAbsolute(count: Int)(implicit ev: MM =:= defaultMM): QueryBuilder[M, Ord, Lim, customMM, Y, H, Q, MinFacetCount, FacetLimit, ST] = {
this.copy(minimumMatch=Some(count.toString))
}
/** Set the query type. This corresponds to the "defType" field.
* Some sample values include "edismax" , "dismax" or just empty to use
* the default query type
* @param qt The query type */
- def useQueryType(qt: String): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] ={
+ def useQueryType(qt: String): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] ={
this.copy(queryType=Some(qt))
}
@@ -284,14 +294,14 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
* query parser)
* @param f The field to query
* @param boost The (optional) amount to boost the query weight for the provided field */
- def queryField[F](f: M => SlashemField[F,M], boost: Double = 1): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] ={
+ def queryField[F](f: M => SlashemField[F,M], boost: Double = 1): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] ={
this.copy(queryFields=WeightedField(f(meta).queryName,boost)::queryFields)
}
/** Same as queryField but takes a list of fields.
* @param fs A list of fields to query
* @param boost The (optional) amount to boost the query weight for the provided field */
- def queryFields(fs: List[M => SlashemField[_,M]], boost: Double = 1): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] ={
+ def queryFields(fs: List[M => SlashemField[_,M]], boost: Double = 1): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] ={
this.copy(queryFields=fs.map(f => WeightedField(f(meta).queryName,boost))++queryFields)
}
@@ -309,37 +319,41 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
* @param pf Enable/disable full phrase boosting
* @param pf2 Enable/disable 2-word shingle phrase boosting
* @param pf3 Enable/disable 3-word shingle phrase boosting */
- def phraseBoost[F](f: M => SlashemField[F,M], boost: Double = 1, pf: Boolean = true, pf2: Boolean = true, pf3: Boolean = true): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] ={
+ def phraseBoost[F](f: M => SlashemField[F,M], boost: Double = 1, pf: Boolean = true, pf2: Boolean = true, pf3: Boolean = true): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] ={
this.copy(phraseBoostFields=PhraseWeightedField(f(meta).name,boost,pf,pf2,pf3)::phraseBoostFields)
}
/** Specify a field to be retrieved. If you want to get back all fields you
* can use a field of name "*"
* @param f Field to be retrieved */
- def fetchField[F](f: M => SlashemField[F,M]): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] = {
+ def fetchField[F](f: M => SlashemField[F,M]): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] = {
this.copy(fieldsToFetch=f(meta).name::fieldsToFetch)
}
/** Same as fetchField but takes multiple fields
* @param fs List of fields to be retrieved */
- def fetchFields(fs: (M => SlashemField[_,M])*): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] = {
+ def fetchFields(fs: (M => SlashemField[_,M])*): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] = {
this.copy(fieldsToFetch=fs.map(f=> f(meta).name).toList++fieldsToFetch)
}
/** Boost a specific field/query. WARNING: NOT TYPE SAFE NO VALIDATION ETC. */
- def boostField(s: String): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] = {
+ def boostField(s: String): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] = {
this.copy(boostFields=WeightedField(s,1)::boostFields)
}
/** Boost a field (type safe version) */
- def boostField[F](f: M => SlashemField[F,M], boost: Double = 1): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] = {
+ def boostField[F](f: M => SlashemField[F,M], boost: Double = 1): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] = {
this.copy(boostFields=WeightedField(f(meta).name,boost)::boostFields)
}
/** Handle a more complex field boost */
- def scoreBoostField(f: M => ScoreBoost): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit] = {
+ def scoreBoostField(f: M => ScoreBoost): QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, ST] = {
this.copy(boostFields=f(meta)::boostFields)
}
+ def customScore(script: String, params: Map[String, Any]) (implicit ev: ST =:= NoScoreModifiers):
+ QueryBuilder[M, Ord, Lim, MM, Y, H, Q, MinFacetCount, FacetLimit, NativeScoreScript] = {
+ this.copy(customScoreScript = Some((script, params)))
+ }
//Print out some debugging information.
def test(): Unit = {
@@ -398,7 +412,7 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
//Auto generated code, is there a better way to do this?
/** Select into a case class */
- def selectCase [F1, F2, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M], create: (Option[F1], List[String] ,Option[F2], List[String]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M], create: (Option[F1], List[String] ,Option[F2], List[String]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -415,10 +429,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
phraseBoostFields, boostFields, start, limit, tieBreaker,
sort, minimumMatch, queryType,
(f1Name::f2Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, F2, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M], create: (Option[F1], Option[F2]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M], create: (Option[F1], Option[F2]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -433,10 +447,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
phraseBoostFields, boostFields, start, limit, tieBreaker,
sort, minimumMatch, queryType,
(f1Name::f2Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, F2, F3, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M], create: (Option[F1], List[String] ,Option[F2], List[String] ,Option[F3], List[String]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, F3, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M], create: (Option[F1], List[String] ,Option[F2], List[String] ,Option[F3], List[String]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -458,10 +472,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
phraseBoostFields, boostFields, start, limit, tieBreaker,
sort, minimumMatch, queryType,
(f1Name::f2Name::f3Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, F2, F3, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M], create: (Option[F1], Option[F2], Option[F3]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, F3, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M], create: (Option[F1], Option[F2], Option[F3]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -480,10 +494,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
phraseBoostFields, boostFields, start, limit, tieBreaker,
sort, minimumMatch, queryType,
(f1Name::f2Name::f3Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, F2, F3, F4, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M], create: (Option[F1], List[String] ,Option[F2], List[String] ,Option[F3], List[String] ,Option[F4], List[String]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, F3, F4, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M], create: (Option[F1], List[String] ,Option[F2], List[String] ,Option[F3], List[String] ,Option[F4], List[String]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -510,10 +524,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
phraseBoostFields, boostFields, start, limit, tieBreaker,
sort, minimumMatch, queryType,
(f1Name::f2Name::f3Name::f4Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, F2, F3, F4, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M], create: (Option[F1], Option[F2], Option[F3], Option[F4]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, F3, F4, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M], create: (Option[F1], Option[F2], Option[F3], Option[F4]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -536,10 +550,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
phraseBoostFields, boostFields, start, limit, tieBreaker,
sort, minimumMatch, queryType,
(f1Name::f2Name::f3Name::f4Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, F2, F3, F4, F5, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M], create: (Option[F1], List[String] ,Option[F2], List[String] ,Option[F3], List[String] ,Option[F4], List[String] ,Option[F5], List[String]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, F3, F4, F5, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M], create: (Option[F1], List[String] ,Option[F2], List[String] ,Option[F3], List[String] ,Option[F4], List[String] ,Option[F5], List[String]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -571,10 +585,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
phraseBoostFields, boostFields, start, limit, tieBreaker,
sort, minimumMatch, queryType,
(f1Name::f2Name::f3Name::f4Name::f5Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, F2, F3, F4, F5, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, F3, F4, F5, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -601,10 +615,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
phraseBoostFields, boostFields, start, limit, tieBreaker,
sort, minimumMatch, queryType,
(f1Name::f2Name::f3Name::f4Name::f5Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, F2, F3, F4, F5, F6, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M], create: (Option[F1], List[String] ,Option[F2], List[String] ,Option[F3], List[String] ,Option[F4], List[String] ,Option[F5], List[String] ,Option[F6], List[String]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, F3, F4, F5, F6, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M], create: (Option[F1], List[String] ,Option[F2], List[String] ,Option[F3], List[String] ,Option[F4], List[String] ,Option[F5], List[String] ,Option[F6], List[String]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -641,10 +655,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
phraseBoostFields, boostFields, start, limit, tieBreaker,
sort, minimumMatch, queryType,
(f1Name::f2Name::f3Name::f4Name::f5Name::f6Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, F2, F3, F4, F5, F6, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, F3, F4, F5, F6, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -675,10 +689,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
phraseBoostFields, boostFields, start, limit, tieBreaker,
sort, minimumMatch, queryType,
(f1Name::f2Name::f3Name::f4Name::f5Name::f6Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, F2, F3, F4, F5, F6, F7, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, F3, F4, F5, F6, F7, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -713,10 +727,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
phraseBoostFields, boostFields, start, limit, tieBreaker,
sort, minimumMatch, queryType,
(f1Name::f2Name::f3Name::f4Name::f5Name::f6Name::f7Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -756,10 +770,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
sort, minimumMatch, queryType,
(f1Name::f2Name::f3Name::f4Name::f5Name::f6Name::f7Name::f8Name::
fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M],f9: M => SlashemField[F9, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8], Option[F9]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M],f9: M => SlashemField[F9, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8], Option[F9]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -803,10 +817,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
sort, minimumMatch, queryType,
(f1Name::f2Name::f3Name::f4Name::f5Name::f6Name::f7Name::f8Name::
f9Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M],f9: M => SlashemField[F9, M],f10: M => SlashemField[F10, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8], Option[F9], Option[F10]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M],f9: M => SlashemField[F9, M],f10: M => SlashemField[F10, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8], Option[F9], Option[F10]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -854,10 +868,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
sort, minimumMatch, queryType,
(f1Name::f2Name::f3Name::f4Name::f5Name::f6Name::f7Name::f8Name::
f9Name::f10Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M],f9: M => SlashemField[F9, M],f10: M => SlashemField[F10, M],f11: M => SlashemField[F11, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8], Option[F9], Option[F10], Option[F11]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M],f9: M => SlashemField[F9, M],f10: M => SlashemField[F10, M],f11: M => SlashemField[F11, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8], Option[F9], Option[F10], Option[F11]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -909,10 +923,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
sort, minimumMatch, queryType,
(f1Name::f2Name::f3Name::f4Name::f5Name::f6Name::f7Name::f8Name::
f9Name::f10Name::f11Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M],f9: M => SlashemField[F9, M],f10: M => SlashemField[F10, M],f11: M => SlashemField[F11, M],f12: M => SlashemField[F12, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8], Option[F9], Option[F10], Option[F11], Option[F12]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M],f9: M => SlashemField[F9, M],f10: M => SlashemField[F10, M],f11: M => SlashemField[F11, M],f12: M => SlashemField[F12, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8], Option[F9], Option[F10], Option[F11], Option[F12]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -968,10 +982,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
sort, minimumMatch, queryType,
(f1Name::f2Name::f3Name::f4Name::f5Name::f6Name::f7Name::f8Name::
f9Name::f10Name::f11Name::f12Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M],f9: M => SlashemField[F9, M],f10: M => SlashemField[F10, M],f11: M => SlashemField[F11, M],f12: M => SlashemField[F12, M],f13: M => SlashemField[F13, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8], Option[F9], Option[F10], Option[F11], Option[F12], Option[F13]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M],f9: M => SlashemField[F9, M],f10: M => SlashemField[F10, M],f11: M => SlashemField[F11, M],f12: M => SlashemField[F12, M],f13: M => SlashemField[F13, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8], Option[F9], Option[F10], Option[F11], Option[F12], Option[F13]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -1031,10 +1045,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
sort, minimumMatch, queryType,
(f1Name::f2Name::f3Name::f4Name::f5Name::f6Name::f7Name::f8Name::
f9Name::f10Name::f11Name::f12Name::f13Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M],f9: M => SlashemField[F9, M],f10: M => SlashemField[F10, M],f11: M => SlashemField[F11, M],f12: M => SlashemField[F12, M],f13: M => SlashemField[F13, M],f14: M => SlashemField[F14, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8], Option[F9], Option[F10], Option[F11], Option[F12], Option[F13], Option[F14]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M],f9: M => SlashemField[F9, M],f10: M => SlashemField[F10, M],f11: M => SlashemField[F11, M],f12: M => SlashemField[F12, M],f13: M => SlashemField[F13, M],f14: M => SlashemField[F14, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8], Option[F9], Option[F10], Option[F11], Option[F12], Option[F13], Option[F14]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -1098,10 +1112,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
sort, minimumMatch, queryType,
(f1Name::f2Name::f3Name::f4Name::f5Name::f6Name::f7Name::f8Name::
f9Name::f10Name::f11Name::f12Name::f13Name::f14Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M],f9: M => SlashemField[F9, M],f10: M => SlashemField[F10, M],f11: M => SlashemField[F11, M],f12: M => SlashemField[F12, M],f13: M => SlashemField[F13, M],f14: M => SlashemField[F14, M],f15: M => SlashemField[F15, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8], Option[F9], Option[F10], Option[F11], Option[F12], Option[F13], Option[F14], Option[F15]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M],f9: M => SlashemField[F9, M],f10: M => SlashemField[F10, M],f11: M => SlashemField[F11, M],f12: M => SlashemField[F12, M],f13: M => SlashemField[F13, M],f14: M => SlashemField[F14, M],f15: M => SlashemField[F15, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8], Option[F9], Option[F10], Option[F11], Option[F12], Option[F13], Option[F14], Option[F15]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -1169,10 +1183,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
sort, minimumMatch, queryType,
(f1Name::f2Name::f3Name::f4Name::f5Name::f6Name::f7Name::f8Name::
f9Name::f10Name::f11Name::f12Name::f13Name::f14Name::f15Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M],f9: M => SlashemField[F9, M],f10: M => SlashemField[F10, M],f11: M => SlashemField[F11, M],f12: M => SlashemField[F12, M],f13: M => SlashemField[F13, M],f14: M => SlashemField[F14, M],f15: M => SlashemField[F15, M],f16: M => SlashemField[F16, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8], Option[F9], Option[F10], Option[F11], Option[F12], Option[F13], Option[F14], Option[F15], Option[F16]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M],f9: M => SlashemField[F9, M],f10: M => SlashemField[F10, M],f11: M => SlashemField[F11, M],f12: M => SlashemField[F12, M],f13: M => SlashemField[F13, M],f14: M => SlashemField[F14, M],f15: M => SlashemField[F15, M],f16: M => SlashemField[F16, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8], Option[F9], Option[F10], Option[F11], Option[F12], Option[F13], Option[F14], Option[F15], Option[F16]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -1245,10 +1259,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
(f1Name::f2Name::f3Name::f4Name::f5Name::f6Name::f7Name::f8Name::
f9Name::f10Name::f11Name::f12Name::f13Name::f14Name::f15Name::f16Name::
fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M],f9: M => SlashemField[F9, M],f10: M => SlashemField[F10, M],f11: M => SlashemField[F11, M],f12: M => SlashemField[F12, M],f13: M => SlashemField[F13, M],f14: M => SlashemField[F14, M],f15: M => SlashemField[F15, M],f16: M => SlashemField[F16, M],f17: M => SlashemField[F17, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8], Option[F9], Option[F10], Option[F11], Option[F12], Option[F13], Option[F14], Option[F15], Option[F16], Option[F17]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M],f9: M => SlashemField[F9, M],f10: M => SlashemField[F10, M],f11: M => SlashemField[F11, M],f12: M => SlashemField[F12, M],f13: M => SlashemField[F13, M],f14: M => SlashemField[F14, M],f15: M => SlashemField[F15, M],f16: M => SlashemField[F16, M],f17: M => SlashemField[F17, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8], Option[F9], Option[F10], Option[F11], Option[F12], Option[F13], Option[F14], Option[F15], Option[F16], Option[F17]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -1325,10 +1339,10 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
(f1Name::f2Name::f3Name::f4Name::f5Name::f6Name::f7Name::f8Name::
f9Name::f10Name::f11Name::f12Name::f13Name::f14Name::f15Name::f16Name::
f17Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
/** Select into a case class */
- def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M],f9: M => SlashemField[F9, M],f10: M => SlashemField[F10, M],f11: M => SlashemField[F11, M],f12: M => SlashemField[F12, M],f13: M => SlashemField[F13, M],f14: M => SlashemField[F14, M],f15: M => SlashemField[F15, M],f16: M => SlashemField[F16, M],f17: M => SlashemField[F17, M],f18: M => SlashemField[F18, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8], Option[F9], Option[F10], Option[F11], Option[F12], Option[F13], Option[F14], Option[F15], Option[F16], Option[F17], Option[F18]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit] = {
+ def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, CC](f1: M => SlashemField[F1, M],f2: M => SlashemField[F2, M],f3: M => SlashemField[F3, M],f4: M => SlashemField[F4, M],f5: M => SlashemField[F5, M],f6: M => SlashemField[F6, M],f7: M => SlashemField[F7, M],f8: M => SlashemField[F8, M],f9: M => SlashemField[F9, M],f10: M => SlashemField[F10, M],f11: M => SlashemField[F11, M],f12: M => SlashemField[F12, M],f13: M => SlashemField[F13, M],f14: M => SlashemField[F14, M],f15: M => SlashemField[F15, M],f16: M => SlashemField[F16, M],f17: M => SlashemField[F17, M],f18: M => SlashemField[F18, M], create: (Option[F1], Option[F2], Option[F3], Option[F4], Option[F5], Option[F6], Option[F7], Option[F8], Option[F9], Option[F10], Option[F11], Option[F12], Option[F13], Option[F14], Option[F15], Option[F16], Option[F17], Option[F18]) => CC)(implicit ev: Y =:= NoSelect): QueryBuilder[M, Ord, Lim, MM, CC, H, Q, MinFacetCount, FacetLimit, ST] = {
val f1Field : SlashemField[F1, M] = f1(meta)
val f1Name : String = f1Field.queryName
@@ -1409,7 +1423,7 @@ case class QueryBuilder[M <: Record[M], Ord, Lim, MM <: MinimumMatchType, Y, H <
(f1Name::f2Name::f3Name::f4Name::f5Name::f6Name::f7Name::f8Name::
f9Name::f10Name::f11Name::f12Name::f13Name::f14Name::f15Name::f16Name::
f17Name::f18Name::fieldsToFetch).distinct,
- facetSettings, hls, hlFragSize, transformer, comment, fallOf, min)
+ facetSettings, customScoreScript, hls, hlFragSize, transformer, comment, fallOf, min)
}
}
object Helpers {
View
85 src/main/scala/com/foursquare/slashem/Schema.scala
@@ -33,7 +33,6 @@ import org.elasticsearch.index.query.{AndFilterBuilder, CustomScoreQueryBuilder,
QueryBuilder => ElasticQueryBuilder}
import org.elasticsearch.node.Node
import org.elasticsearch.node.NodeBuilder._
-
import org.elasticsearch.search.facet.AbstractFacetBuilder
import org.elasticsearch.search.facet.terms.TermsFacetBuilder
import org.elasticsearch.search.facet.terms.strings.InternalStringTermsFacet
@@ -460,30 +459,30 @@ trait SlashemSchema[M <: Record[M]] extends Record[M] {
})
}
-
- def where[F](c: M => Clause[F]): QueryBuilder[M, Unordered, Unlimited, defaultMM, NoSelect, NoHighlighting, NoQualityFilter, NoMinimumFacetCount, Unlimited] = {
+ def where[F](c: M => Clause[F]): QueryBuilder[M, Unordered, Unlimited, defaultMM, NoSelect, NoHighlighting, NoQualityFilter, NoMinimumFacetCount, Unlimited, NoScoreModifiers] = {
QueryBuilder(self, c(self), filters=Nil, boostQueries=Nil, queryFields=Nil,
phraseBoostFields=Nil, boostFields=Nil, start=None, limit=None,
tieBreaker=None, sort=None, minimumMatch=None ,queryType=None,
fieldsToFetch=Nil, facetSettings=FacetSettings(facetFieldList=Nil,
facetMinCount=None,
facetLimit=None),
- hls=None, hlFragSize=None, creator=None, comment=None, fallOf=None, min=None)
+ customScoreScript=None, hls=None, hlFragSize=None, creator=None,
+ comment=None, fallOf=None, min=None)
}
- def query[Ord, Lim, MM <: MinimumMatchType, Y, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim](timeout: Duration, qb: QueryBuilder[M, Ord, Lim, MM, Y, H, Q, FC, FLim]): SearchResults[M, Y]
- def queryFuture[Ord, Lim, MM <: MinimumMatchType, Y, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim](qb: QueryBuilder[M, Ord, Lim, MM, Y, H, Q, FC, FLim]): Future[SearchResults[M, Y]]
+ def query[Ord, Lim, MM <: MinimumMatchType, Y, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim, ST <: ScoreType](timeout: Duration, qb: QueryBuilder[M, Ord, Lim, MM, Y, H, Q, FC, FLim, ST]): SearchResults[M, Y]
+ def queryFuture[Ord, Lim, MM <: MinimumMatchType, Y, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim, ST <: ScoreType](qb: QueryBuilder[M, Ord, Lim, MM, Y, H, Q, FC, FLim, ST]): Future[SearchResults[M, Y]]
}
trait ElasticSchema[M <: Record[M]] extends SlashemSchema[M] {
self: M with SlashemSchema[M] =>
def meta: ElasticMeta[M]
- def query[Ord, Lim, MM <: MinimumMatchType, Y, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim](timeout: Duration, qb: QueryBuilder[M, Ord, Lim, MM, Y, H, Q, FC, FLim]):
+ def query[Ord, Lim, MM <: MinimumMatchType, Y, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim, ST <: ScoreType](timeout: Duration, qb: QueryBuilder[M, Ord, Lim, MM, Y, H, Q, FC, FLim, ST]):
SearchResults[M, Y] = {
queryFuture(qb, Some(timeout))(timeout)
}
- def queryFuture[Ord, Lim, MM <: MinimumMatchType, Y, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim](qb: QueryBuilder[M, Ord, Lim, MM, Y, H, Q, FC, FLim]):
+ def queryFuture[Ord, Lim, MM <: MinimumMatchType, Y, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim, ST <: ScoreType](qb: QueryBuilder[M, Ord, Lim, MM, Y, H, Q, FC, FLim, ST]):
Future[SearchResults[M, Y]] = {
elasticQueryFuture(qb, buildElasticQuery(qb), None)
}
@@ -492,12 +491,12 @@ trait ElasticSchema[M <: Record[M]] extends SlashemSchema[M] {
* @qb: The query builder representing the query to be executed
* @timeoutOpt: An option type that requests a server side timeout for the query
*/
- def queryFuture[Ord, Lim, MM <: MinimumMatchType, Y, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim](qb: QueryBuilder[M, Ord, Lim, MM, Y, H, Q, FC, FLim], timeoutOpt: Option[Duration]):
+ def queryFuture[Ord, Lim, MM <: MinimumMatchType, Y, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim, ST <: ScoreType](qb: QueryBuilder[M, Ord, Lim, MM, Y, H, Q, FC, FLim, ST], timeoutOpt: Option[Duration]):
Future[SearchResults[M, Y]] = {
elasticQueryFuture(qb, buildElasticQuery(qb), timeoutOpt)
}
- def elasticQueryFuture[Ord, Lim, MM <: MinimumMatchType, Y, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim](qb: QueryBuilder[M, Ord, Lim, MM, Y, H, Q, FC, FLim], query: ElasticQueryBuilder, timeoutOpt: Option[Duration]): Future[SearchResults[M, Y]] = {
+ def elasticQueryFuture[Ord, Lim, MM <: MinimumMatchType, Y, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim, ST <: ScoreType](qb: QueryBuilder[M, Ord, Lim, MM, Y, H, Q, FC, FLim, ST], query: ElasticQueryBuilder, timeoutOpt: Option[Duration]): Future[SearchResults[M, Y]] = {
val esfp = meta.executorServiceFuturePool
val searchResultsFuture = esfp {
@@ -614,7 +613,8 @@ trait ElasticSchema[M <: Record[M]] extends SlashemSchema[M] {
Response(this, creator, hitCount, start, docs,
fallOff=fallOff, min=min, fieldFacet))
}
- def buildElasticQuery[Ord, Lim, MM <: MinimumMatchType, Y, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim](qb: QueryBuilder[M, Ord, Lim, MM, Y, H, Q, FC, FLim]): ElasticQueryBuilder = {
+
+ def buildElasticQuery[Ord, Lim, MM <: MinimumMatchType, Y, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim, ST <: ScoreType](qb: QueryBuilder[M, Ord, Lim, MM, Y, H, Q, FC, FLim, ST]): ElasticQueryBuilder = {
val baseQuery: ElasticQueryBuilder= qb.clauses.elasticExtend(qb.queryFields,
qb.phraseBoostFields,
qb.minimumMatch)
@@ -624,12 +624,16 @@ trait ElasticSchema[M <: Record[M]] extends SlashemSchema[M] {
case _ => filteredQuery(baseQuery,combineFilters(qb.filters.map(_.elasticFilter(qb.queryFields))))
}
//Apply any custom scoring rules (aka emulating Solr's bq/bf)
- val boostedQuery = qb.boostFields match {
- case Nil => fq
- case _ => boostFields(fq, qb.boostFields)
+ val scoredQuery = qb.boostFields match {
+ case Nil => qb.customScoreScript match {
+ case Some((script, params)) => scoreWithScript(fq, script, params)
+ case None => fq
+ }
+ case _ => scoreFields(fq, qb.boostFields)
}
- boostedQuery
+ scoredQuery
}
+
def termFacetQuery(facetFields: List[Ast.Field], facetLimit: Option[Int]): List[AbstractFacetBuilder] = {
val fieldNames = facetFields.map(_.boost())
val facetQueries = fieldNames.map(name => {
@@ -640,43 +644,62 @@ trait ElasticSchema[M <: Record[M]] extends SlashemSchema[M] {
}
case _ => q
}
- }
- )
+ })
facetQueries
}
- def boostFields(query: ElasticQueryBuilder, boostFields: List[ScoreBoost]): ElasticQueryBuilder = {
- val boostedQuery = new CustomScoreQueryBuilder(query)
- val boostedQuerys = boostFields.map(_.elasticBoost)
- val params = boostedQuerys.flatMap(_._1)
- val scriptSrc = boostedQuerys.map(_._2).mkString(" + ")
+
+ /**
+ * Custom score the fields which have scoreboosts
+ */
+ 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 paramNames = (1 to params.length).map("p"+_)
val script = scriptSrc.format(paramNames:_*)
- val keyedParams = paramNames zip params
- keyedParams.foreach(p => {boostedQuery.param(p._1,p._2)})
+ val namesAndParams = paramNames.zip(params).toMap
val scoreScript = "_score * (1 +"+ script + " )"
- boostedQuery.script(scoreScript)
+ scoreWithScript(query, scoreScript, namesAndParams, false)
}
+
+ /**
+ * Add the provided script and its params to the query and build a
+ * CustomScoreQuery with it.
+ */
+ def scoreWithScript(query: ElasticQueryBuilder, script: String,
+ namesAndParams: Map[String, Any], native: Boolean = true): ElasticQueryBuilder = {
+ val customScoreQuery = new CustomScoreQueryBuilder(query).script(script)
+ native match {
+ case true => customScoreQuery.lang("native")
+ case false => customScoreQuery.lang("mvel")
+ }
+ for ((name, param) <- namesAndParams) {
+ customScoreQuery.param(name, param)
+ }
+ customScoreQuery
+ }
+
def combineFilters(filters: List[ElasticFilterBuilder]): ElasticFilterBuilder = {
new AndFilterBuilder(filters:_*)
}
-
}
+
trait SolrSchema[M <: Record[M]] extends SlashemSchema[M] {
self: M with SlashemSchema[M] =>
def meta: SolrMeta[M]
// 'Where' is the entry method for a SolrRogue query.
- def queryParams[Ord, Lim, MM <: MinimumMatchType, Select, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim](qb: QueryBuilder[M, Ord, Lim, MM, Select, H, Q, FC, FLim]): Seq[(String, String)] = queryParamsWithBounds(qb,qb.start, qb.limit)
+ def queryParams[Ord, Lim, MM <: MinimumMatchType, Select, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim, ST <: ScoreType](qb: QueryBuilder[M, Ord, Lim, MM, Select, H, Q, FC, FLim, ST]): Seq[(String, String)] = queryParamsWithBounds(qb,qb.start, qb.limit)
- def queryParamsWithBounds[Ord, Lim, MM <: MinimumMatchType, Select, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim](qb: QueryBuilder[M, Ord, Lim, MM, Select, H, Q, FC, FLim], qstart: Option[Long], qrows: Option[Long]): Seq[(String,String)] = {
+ def queryParamsWithBounds[Ord, Lim, MM <: MinimumMatchType, Select, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim, ST <: ScoreType](qb: QueryBuilder[M, Ord, Lim, MM, Select, H, Q, FC, FLim, ST], qstart: Option[Long], qrows: Option[Long]): Seq[(String,String)] = {
val bounds = List(("start" -> (qstart.getOrElse {qb.DefaultStart}).toString),
("rows" -> (qrows.getOrElse {qb.DefaultLimit}).toString))
bounds ++ queryParamsNoBounds(qb)
}
//This is the part which generates most of the solr request
- def queryParamsNoBounds[Ord, Lim, MM <: MinimumMatchType, Select, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim](qb: QueryBuilder[M, Ord, Lim, MM, Select, H, Q, FC, FLim]): Seq[(String,String)] = {
+ def queryParamsNoBounds[Ord, Lim, MM <: MinimumMatchType, Select, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim, ST <: ScoreType](qb: QueryBuilder[M, Ord, Lim, MM, Select, H, Q, FC, FLim, ST]): Seq[(String,String)] = {
//The actual query
val p = List(("q" -> qb.clauses.extend))
@@ -752,12 +775,12 @@ trait SolrSchema[M <: Record[M]] extends SlashemSchema[M] {
}
- def query[Ord, Lim, MM <: MinimumMatchType, Y, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim](timeout: Duration, qb: QueryBuilder[M, Ord, Lim, MM, Y, H, Q, FC, FLim]):
+ def query[Ord, Lim, MM <: MinimumMatchType, Y, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim, ST <: ScoreType](timeout: Duration, qb: QueryBuilder[M, Ord, Lim, MM, Y, H, Q, FC, FLim, ST]):
SearchResults[M, Y] = {
queryFuture(qb)(timeout)
}
- def queryFuture[Ord, Lim, MM <: MinimumMatchType, Y, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim](qb: QueryBuilder[M, Ord, Lim, MM, Y, H, Q, FC, FLim]):
+ def queryFuture[Ord, Lim, MM <: MinimumMatchType, Y, H <: Highlighting, Q <: QualityFilter, FC <: FacetCount, FLim, ST <: ScoreType](qb: QueryBuilder[M, Ord, Lim, MM, Y, H, Q, FC, FLim, ST]):
Future[SearchResults[M, Y]] = {
solrQueryFuture(qb.creator, queryParams(qb), qb.fieldsToFetch, qb.fallOf, qb.min)
}
View
1 src/test/resources/es-plugin.properties
@@ -0,0 +1 @@
+plugin=com.foursquare.elasticsearch.scorer.FourSquareScorePlugin
View
17 src/test/scala/com/foursquare/elasticsearch/scorer/FoursquareScorePlugin.scala
@@ -0,0 +1,17 @@
+package com.foursquare.elasticsearch.scorer;
+
+import org.elasticsearch.plugins.AbstractPlugin;
+import org.elasticsearch.script.ScriptModule;
+
+/**
+ * Provides a fast* score script for our primary use case
+ */
+class FourSquareScorePlugin extends AbstractPlugin {
+ override def name(): String = "foursquare";
+
+ override def description(): String = "foursquare plugin";
+
+ def onModule(module: ScriptModule): Unit = {
+ module.registerScript("distance_score_magic", classOf[ScoreFactory]);
+ }
+}
View
42 ...ala/com/foursquare/elasticsearch/scorer/script/CombinedDistanceDocumentScorerScript.scala
@@ -0,0 +1,42 @@
+package com.foursquare.elasticsearch.scorer;
+
+import org.elasticsearch.common.Nullable;
+import org.elasticsearch.common.xcontent.support.XContentMapValues;
+import org.elasticsearch.index.field.data.NumericDocFieldData;
+import org.elasticsearch.index.mapper.geo.GeoPointDocFieldData;
+import org.elasticsearch.script.AbstractFloatSearchScript;
+import org.elasticsearch.script.ExecutableScript;
+import org.elasticsearch.script.NativeScriptFactory;
+import org.elasticsearch.search.lookup.DocLookup;
+
+import java.util.Map;
+
+/**
+ * Note: assumes that the point field is point
+ */
+case class CombinedDistanceDocumentScorerSearchScript(val lat: Double,
+ val lon: Double,
+ val weight1: Float,
+ val weight2: Float) extends AbstractFloatSearchScript {
+
+ override def runAsFloat(): Float = {
+ val myDoc: DocLookup = doc();
+ val point: GeoPointDocFieldData = myDoc.get("point").asInstanceOf[GeoPointDocFieldData];
+ val popularity: Double = myDoc.numeric("decayedPopularity1").asInstanceOf[NumericDocFieldData[_]].getDoubleValue()
+ // up to you to remove score from here or not..., also, possibly, add more weights options
+ val myScore: Float = (score() *
+ (1 + weight1 * math.pow(((1.0 * (math.pow(point.distanceInKm(lat, lon), 2.0))) + 1.0), -1.0)
+ + popularity * weight2)).toFloat;
+ myScore
+ }
+}
+
+class ScoreFactory extends NativeScriptFactory {
+ def newScript(@Nullable params: Map[String, Object]): ExecutableScript = {
+ val lat: Double = if (params == null) 1 else XContentMapValues.nodeDoubleValue(params.get("lat"), 0);
+ val lon: Double = if (params == null) 1 else XContentMapValues.nodeDoubleValue(params.get("lon"), 0);
+ val weight1: Float = if(params == null) 1 else XContentMapValues.nodeFloatValue(params.get("weight1"), 5000.0f);
+ val weight2: Float = if(params == null) 1 else XContentMapValues.nodeFloatValue(params.get("weight2"), 0.05f);
+ return new CombinedDistanceDocumentScorerSearchScript(lat, lon, weight1, weight2);
+ }
+}
View
40 src/test/scala/com/foursquare/slashem/ElasticQueryTest.scala
@@ -1,4 +1,5 @@
package com.foursquare.slashem
+import com.foursquare.elasticsearch.scorer.FourSquareScorePlugin
import com.foursquare.slashem._
import com.twitter.util.Duration
@@ -14,6 +15,7 @@ import org.scalacheck.Arbitrary.arbitrary
import org.specs.SpecsMatchers
import org.specs.matcher.ScalaCheckMatchers
+//import org.elasticsearch.common.settings.ImmutableSettings
import org.elasticsearch.node.NodeBuilder._
import org.elasticsearch.node.Node
import org.elasticsearch.client.Requests;
@@ -67,7 +69,7 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
def testRecipGeoBoostTimeout {
val geoLat = 74
val geoLong = -31
- val r = ESimpleGeoPanda where (_.name contains "lolerskates") scoreBoostField(_.pos recipSqeGeoDistance(geoLat, geoLong, 1, 5000, 1)) fetch(Duration(0,TimeUnit.MILLISECONDS))
+ val r = ESimpleGeoPanda where (_.name contains "lolerskates") scoreBoostField(_.point recipSqeGeoDistance(geoLat, geoLong, 1, 5000, 1)) fetch(Duration(0,TimeUnit.MILLISECONDS))
}
@Test
@@ -183,7 +185,7 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
}
@Test
def geoOrderDesc {
- var r = ESimpleGeoPanda where (_.name contains "ordertest") complexOrderDesc(_.pos sqeGeoDistance(74.0,-31.0)) fetch()
+ var r = ESimpleGeoPanda where (_.name contains "ordertest") complexOrderDesc(_.point sqeGeoDistance(74.0,-31.0)) fetch()
Assert.assertEquals(2,r.response.results.length)
val doc0 = r.response.oidScorePair.apply(0)
val doc1= r.response.oidScorePair.apply(1)
@@ -192,7 +194,7 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
}
@Test
def geoOrderAsc {
- var r = ESimpleGeoPanda where (_.name contains "ordertest") complexOrderAsc(_.pos sqeGeoDistance(74.0,-31.0)) fetch()
+ var r = ESimpleGeoPanda where (_.name contains "ordertest") complexOrderAsc(_.point sqeGeoDistance(74.0,-31.0)) fetch()
Assert.assertEquals(2,r.response.results.length)
val doc0 = r.response.oidScorePair.apply(0)
val doc1= r.response.oidScorePair.apply(1)
@@ -201,7 +203,7 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
}
@Test
def geoOrderIntAsc {
- var r = ESimpleGeoPanda where (_.name contains "ordertest") complexOrderAsc(_.pos sqeGeoDistance(74,-31)) fetch()
+ var r = ESimpleGeoPanda where (_.name contains "ordertest") complexOrderAsc(_.point sqeGeoDistance(74,-31)) fetch()
Assert.assertEquals(2,r.response.results.length)
val doc0 = r.response.oidScorePair.apply(0)
val doc1= r.response.oidScorePair.apply(1)
@@ -277,7 +279,7 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
val geoLat = 74
val geoLong = -31
val r1 = ESimpleGeoPanda where (_.name contains "lolerskates") fetch()
- val r2 = ESimpleGeoPanda where (_.name contains "lolerskates") scoreBoostField(_.pos sqeGeoDistance(geoLat, geoLong)) fetch()
+ val r2 = ESimpleGeoPanda where (_.name contains "lolerskates") scoreBoostField(_.point sqeGeoDistance(geoLat, geoLong)) fetch()
Assert.assertEquals(r1.response.results.length,2)
Assert.assertEquals(r2.response.results.length,2)
Assert.assertTrue(r2.response.results.apply(0).score.value > r1.response.results.apply(0).score.value)
@@ -287,17 +289,17 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
//Test GeoBoosting. Note will actually make further away document come up first
val geoLat = 74
val geoLong = -31
- val r = ESimpleGeoPanda where (_.name contains "lolerskates") scoreBoostField(_.pos sqeGeoDistance(geoLat, geoLong)) fetch()
+ val r = ESimpleGeoPanda where (_.name contains "lolerskates") scoreBoostField(_.point sqeGeoDistance(geoLat, geoLong)) fetch()
Assert.assertEquals(r.response.results.length,2)
- Assert.assertEquals(r.response.results.apply(0).pos.value._1,74.0,0.9)
+ Assert.assertEquals(r.response.results.apply(0).point.value._1,74.0,0.9)
}
@Test
def testRecipGeoBoost {
val geoLat = 74
val geoLong = -31
val r1 = ESimpleGeoPanda where (_.name contains "lolerskates") fetch()
- val r2 = ESimpleGeoPanda where (_.name contains "lolerskates") scoreBoostField(_.pos recipSqeGeoDistance(geoLat, geoLong, 1, 5000, 1)) fetch()
+ val r2 = ESimpleGeoPanda where (_.name contains "lolerskates") scoreBoostField(_.point recipSqeGeoDistance(geoLat, geoLong, 1, 5000, 1)) fetch()
Assert.assertEquals(r1.response.results.length,2)
Assert.assertEquals(r2.response.results.length,2)
Assert.assertTrue(r2.response.results.apply(0).score.value > r1.response.results.apply(0).score.value)
@@ -404,12 +406,20 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
Assert.assertEquals(res1.response.results.length, 1)
}
+ @Test
+ def testCustomScoreScripts {
+ val params: Map[String, Any] = Map("lat" -> -31.1, "lon" -> 74.0, "weight" -> 2000, "weight2" -> 0.03)
+ val response1 = ESimpleGeoPanda where(_.name contains "lolerskates") customScore("distance_score_magic", params) fetch()
+ Assert.assertEquals(response1.response.results.length, 2)
+ }
+
@Before
def hoboPrepIndex() {
ESimplePanda.meta.node = ElasticNode.node
ESimpleGeoPanda.meta.node = ElasticNode.node
- val client = ESimplePanda.meta.client
+ val plugin = new FourSquareScorePlugin()
+ val client = ESimplePanda.meta.client
//Set up the geo panda index
val geoClient = ESimpleGeoPanda.meta.client
@@ -421,7 +431,7 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
val mapping = """
{ "slashemdoc" :{
"properties" : {
- "pos" : { type: "geo_point" }
+ "point" : { type: "geo_point" }
}
}}"""
val mappingReq = Requests.putMappingRequest(ESimpleGeoPanda.meta.indexName).source(mapping).`type`("slashemdoc")
@@ -433,16 +443,18 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
val geodoc1 = geoClient.prepareIndex(ESimpleGeoPanda.meta.indexName,ESimpleGeoPanda.meta.docType,"4c809f4251ada1cdc3790b10").setSource(jsonBuilder()
.startObject()
.field("name","lolerskates")
- .field("pos",74.0,-31.1)
+ .field("point",74.0,-31.1)
.field("id","4c809f4251ada1cdc3790b10")
+ .field("decayedPopularity1", .5)
.endObject()
).execute()
.actionGet();
val geodoc2 = geoClient.prepareIndex(ESimpleGeoPanda.meta.indexName,ESimpleGeoPanda.meta.docType,"4c809f4251ada1cdc3790b11").setSource(jsonBuilder()
.startObject()
.field("name","lolerskates")
.field("id","4c809f4251ada1cdc3790b11")
- .field("pos",74.0,-31.0)
+ .field("point",74.0,-31.0)
+ .field("decayedPopularity1", 21.2)
.endObject()
).execute()
.actionGet();
@@ -540,15 +552,15 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
.startObject()
.field("name","ordertest")
.field("id","4c809f4251ada1cdc3790b16")
- .field("pos",74.0,-32.0)
+ .field("point",74.0,-32.0)
.endObject()
).execute()
.actionGet();
val geoOrderdoc2 = geoClient.prepareIndex(ESimpleGeoPanda.meta.indexName,ESimpleGeoPanda.meta.docType,"4c809f4251ada1cdc3790b17").setSource(jsonBuilder()
.startObject()
.field("name","ordertest")
.field("id","4c809f4251ada1cdc3790b17")
- .field("pos",74.0,-31.0)
+ .field("point",74.0,-31.0)
.endObject()
).execute()
.actionGet();
View
3 src/test/scala/com/foursquare/slashem/ElasticTest.scala
@@ -38,5 +38,6 @@ class ESimpleGeoPanda extends ElasticSchema[ESimpleGeoPanda] {
object id extends SlashemObjectIdField(this)
object name extends SlashemStringField(this)
object score extends SlashemDoubleField(this)
- object pos extends SlashemPointField(this)
+ object point extends SlashemPointField(this)
+ object decayedPopularity1 extends SlashemDoubleField(this)
}

0 comments on commit 95c71e7

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