Skip to content

Commit

Permalink
#88 Adapt queries to use join field instead of _type
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed May 28, 2019
1 parent c01b259 commit aa3d478
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions app/org/elastic4play/services/QueryDSL.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,19 @@ object QueryDSL {
def groupByCaterogy(aggregationName: Option[String], categories: Map[String, QueryDef], selectables: Agg*) =
new GroupByCategory(aggregationName.getOrElse("categories"), categories, selectables)

private def nestedField(field: String, q: String Query) =
field
.split("\\.")
.init
.inits
.toSeq
.init
.foldLeft(q(field)) {
case (queryDef, subName) nestedQuery(subName.mkString(".")).query(queryDef).scoreMode(ScoreMode.None)
}
private def nestedField(field: String, q: String Query) = field match {
case "_type" q("relations")
case _
field
.split("\\.")
.init
.inits
.toSeq
.init
.foldLeft(q(field)) {
case (queryDef, subName) nestedQuery(subName.mkString(".")).query(queryDef).scoreMode(ScoreMode.None)
}
}

implicit class SearchField(field: String) /*extends BuildableTermsQueryImplicits*/ {
implicit val stringTermsQueryBuilder = new BuildableTermsQuery[String] {
Expand Down

0 comments on commit aa3d478

Please sign in to comment.