File tree Expand file tree Collapse file tree 4 files changed +10
-5
lines changed
sql/src/main/scala/app/softnetwork/elastic/sql/query Expand file tree Collapse file tree 4 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -215,7 +215,7 @@ object NestedElements {
215215 val nestedParentsPath : collection.mutable.Map [String , (NestedElement , Seq [NestedElement ])] =
216216 collection.mutable.Map .empty
217217
218- val distinctNestedElements = nestedElements.distinctBy (_.path)
218+ val distinctNestedElements = nestedElements.groupBy (_.path).map(_._2.head).toList
219219
220220 @ tailrec
221221 def getNestedParents (
Original file line number Diff line number Diff line change @@ -15,5 +15,5 @@ case class Having(criteria: Option[Criteria]) extends Updateable {
1515 override def validate (): Either [String , Unit ] = criteria.map(_.validate()).getOrElse(Right (()))
1616
1717 def nestedElements : Seq [NestedElement ] =
18- criteria.map(_.nestedElements).getOrElse(Seq .empty).distinctBy (_.path)
18+ criteria.map(_.nestedElements).getOrElse(Seq .empty).groupBy (_.path).map(_._2.head).toList
1919}
Original file line number Diff line number Diff line change @@ -29,12 +29,17 @@ case class SQLSearchRequest(
2929 .filterNot(_.aggregation)
3030 .filter(_.nested)
3131 .groupBy(_.identifier.innerHitsName.getOrElse(" " ))
32- lazy val nested : Seq [NestedElement ] = from.unnests.map(toNestedElement).distinctBy(_.path)
32+ lazy val nested : Seq [NestedElement ] =
33+ from.unnests.map(toNestedElement).groupBy(_.path).map(_._2.head).toList
3334 private [this ] lazy val nestedFieldsWithoutCriteria : Map [String , Seq [Field ]] = {
3435 // nested fields that are not part of where, having or group by clauses
3536 val innerHitsWithCriteria = (where.map(_.nestedElements).getOrElse(Seq .empty) ++
3637 having.map(_.nestedElements).getOrElse(Seq .empty) ++
37- groupBy.map(_.nestedElements).getOrElse(Seq .empty)).distinctBy(_.path).map(_.innerHitsName)
38+ groupBy.map(_.nestedElements).getOrElse(Seq .empty))
39+ .groupBy(_.path)
40+ .map(_._2.head)
41+ .toList
42+ .map(_.innerHitsName)
3843 val ret = nestedFields.filterNot { case (innerHitsName, _) =>
3944 innerHitsWithCriteria.contains(innerHitsName)
4045 }
Original file line number Diff line number Diff line change @@ -790,7 +790,7 @@ case class Where(criteria: Option[Criteria]) extends Updateable {
790790 }
791791
792792 def nestedElements : Seq [NestedElement ] = criteria match {
793- case Some (c) => c.nestedElements.distinctBy (_.path)
793+ case Some (c) => c.nestedElements.groupBy (_.path).map(_._2.head).toList
794794 case _ => Nil
795795 }
796796}
You can’t perform that action at this time.
0 commit comments