1 /*
2  *  Make.org Core API
3  *  Copyright (C) 2018 Make.org
4  *
5  * This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU Affero General Public License as
7  *  published by the Free Software Foundation, either version 3 of the
8  *  License, or (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU Affero General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Affero General Public License
16  *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
17  *
18  */
19 
20 package org.make.api.organisation
21 
22 import akka.Done
23 import cats.implicits._
24 import com.sksamuel.elastic4s.Index
25 import com.sksamuel.elastic4s.circe._
26 import com.sksamuel.elastic4s.ElasticDsl._
27 import com.sksamuel.elastic4s.requests.common.RefreshPolicy
28 import com.sksamuel.elastic4s.requests.searches.SearchRequest
29 import com.sksamuel.elastic4s.requests.searches.queries.compound.BoolQuery
30 import grizzled.slf4j.Logging
31 import io.circe.{Json, Printer}
32 import org.make.api.technical.elasticsearch._
33 import org.make.core.CirceFormatters
34 import org.make.core.technical.Pagination
35 import org.make.core.user.indexed.{IndexedOrganisation, OrganisationSearchResult}
36 import org.make.core.user.{OrganisationSearchFilters, OrganisationSearchQuery, SlugSearchFilter, UserId}
37 
38 import scala.concurrent.ExecutionContext.Implicits.global
39 import scala.concurrent.Future
40 
41 trait OrganisationSearchEngineComponent {
42   def elasticsearchOrganisationAPI: OrganisationSearchEngine
43 }
44 
45 trait OrganisationSearchEngine {
46   def findOrganisationById(organisationId: UserId): Future[Option[IndexedOrganisation]]
47   def findOrganisationBySlug(slug: String): Future[Option[IndexedOrganisation]]
48   def searchOrganisations(query: OrganisationSearchQuery): Future[OrganisationSearchResult]
49   def indexOrganisation(record: IndexedOrganisation, mayBeIndex: Option[Index] = None): Future[Done]
50   def indexOrganisations(records: Seq[IndexedOrganisation], mayBeIndex: Option[Index] = None): Future[Done]
51   def updateOrganisation(record: IndexedOrganisation, mayBeIndex: Option[Index] = None): Future[Done]
52 }
53 
54 object OrganisationSearchEngine {
55   val organisationIndexName: String = "organisation"
56 }
57 
58 trait DefaultOrganisationSearchEngineComponent extends OrganisationSearchEngineComponent with CirceFormatters {
59   self: ElasticsearchConfigurationComponent with ElasticsearchClientComponent =>
60 
61   override lazy val elasticsearchOrganisationAPI: OrganisationSearchEngine = new DefaultOrganisationSearchEngine
62 
63   class DefaultOrganisationSearchEngine extends OrganisationSearchEngine with Logging {
64 
65     private lazy val client = elasticsearchClient.client
66 
67     private val organisationAlias: Index =
68       elasticsearchConfiguration.organisationAliasName
69 
70     // TODO remove once elastic4s-circe upgrades to circe 0.14
71     private implicit val printer: Json => String = Printer.noSpaces.print
72 
73     override def findOrganisationById(organisationId: UserId): Future[Option[IndexedOrganisation]] = {
74       client
75         .executeAsFuture(get(organisationAlias, organisationId.value))
76         .map(_.toOpt[IndexedOrganisation])
77     }
78 
79     override def findOrganisationBySlug(slug: String): Future[Option[IndexedOrganisation]] = {
80       val query = OrganisationSearchQuery(
81         filters = OrganisationSearchFilters.parse(slug = Some(SlugSearchFilter(slug))),
82         limit = Some(Pagination.Limit(1))
83       )
84       val searchFilters = OrganisationSearchFilters.getOrganisationSearchFilters(query)
85       val request = search(organisationAlias)
86         .bool(BoolQuery(must = searchFilters))
87         .from(0)
88         .size(1)
89         .trackTotalHits(true)
90 
91       client.executeAsFuture {
92         request
93       }.map(_.to[IndexedOrganisation]).map(_.headOption)
94     }
95 
96     override def searchOrganisations(query: OrganisationSearchQuery): Future[OrganisationSearchResult] = {
97       val searchFilters = OrganisationSearchFilters.getOrganisationSearchFilters(query)
98       val request: SearchRequest = search(organisationAlias)
99         .bool(BoolQuery(must = searchFilters))
100         .sortBy(OrganisationSearchFilters.getSort(query).toList)
101         .size(OrganisationSearchFilters.getLimitSearch(query))
102         .from(OrganisationSearchFilters.getSkipSearch(query))
103         .trackTotalHits(true)
104 
105       val requestSorted = query.sortAlgorithm match {
106         case None                => request
107         case Some(sortAlgorithm) => sortAlgorithm.sortDefinition(request)
108       }
109 
110       client
111         .executeAsFuture(requestSorted)
112         .map { response =>
113           OrganisationSearchResult(total = response.totalHits, results = response.to[IndexedOrganisation])
114         }
115     }
116 
117     override def indexOrganisation(record: IndexedOrganisation, mayBeIndex: Option[Index]): Future[Done] = {
118       val index = mayBeIndex.getOrElse(organisationAlias)
119       client
120         .executeAsFuture(indexInto(index).doc(record).refresh(RefreshPolicy.IMMEDIATE).id(record.organisationId.value))
121         .as(Done)
122     }
123 
124     override def indexOrganisations(records: Seq[IndexedOrganisation], mayBeIndex: Option[Index]): Future[Done] = {
125       val index = mayBeIndex.getOrElse(organisationAlias)
126       client
127         .executeAsFuture(bulk(records.map { record =>
128           indexInto(index).doc(record).refresh(RefreshPolicy.IMMEDIATE).id(record.organisationId.value)
129         }))
130         .as(Done)
131     }
132 
133     override def updateOrganisation(record: IndexedOrganisation, mayBeIndex: Option[Index]): Future[Done] = {
134       val index = mayBeIndex.getOrElse(organisationAlias)
135       client
136         .executeAsFuture(
137           updateById(index, record.organisationId.value)
138             .doc(record)
139             .refresh(RefreshPolicy.IMMEDIATE)
140         )
141         .as(Done)
142     }
143 
144   }
145 }
Line Stmt Id Pos Tree Symbol Tests Code
55 8566 2385 - 2399 Literal <nosymbol> "organisation"
68 8225 2907 - 2955 ApplyImplicitView com.sksamuel.elastic4s.Index.toIndex org.scalatest.testsuite elastic4s.this.Index.toIndex(DefaultOrganisationSearchEngineComponent.this.elasticsearchConfiguration.organisationAliasName)
71 8829 3071 - 3093 Apply io.circe.Printer.print io.circe.Printer.noSpaces.print(json)
75 8499 3235 - 3235 Select com.sksamuel.elastic4s.handlers.get.GetHandlers.GetHandler com.sksamuel.elastic4s.ElasticDsl.GetHandler
75 7888 3236 - 3280 Apply com.sksamuel.elastic4s.api.GetApi.get com.sksamuel.elastic4s.ElasticDsl.get(DefaultOrganisationSearchEngine.this.organisationAlias, organisationId.value)
75 8142 3235 - 3235 Select scala.concurrent.ExecutionContext.Implicits.global scala.concurrent.ExecutionContext.Implicits.global
75 8638 3240 - 3257 Select org.make.api.organisation.DefaultOrganisationSearchEngineComponent.DefaultOrganisationSearchEngine.organisationAlias DefaultOrganisationSearchEngine.this.organisationAlias
75 7950 3235 - 3235 Apply scala.reflect.ManifestFactory.classType scala.reflect.ManifestFactory.classType[com.sksamuel.elastic4s.requests.get.GetResponse](classOf[com.sksamuel.elastic4s.requests.get.GetResponse])
75 8248 3259 - 3279 Select org.make.core.user.UserId.value organisationId.value
76 8445 3294 - 3294 Select scala.concurrent.ExecutionContext.Implicits.global scala.concurrent.ExecutionContext.Implicits.global
76 8813 3295 - 3323 ApplyToImplicitArgs com.sksamuel.elastic4s.Hit.toOpt x$1.toOpt[org.make.core.user.indexed.IndexedOrganisation](com.sksamuel.elastic4s.circe.`package`.hitReaderWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.decoder))
76 8244 3204 - 3324 ApplyToImplicitArgs scala.concurrent.Future.map org.make.api.technical.elasticsearch.`package`.RichHttpClient(DefaultOrganisationSearchEngine.this.client).executeAsFuture[com.sksamuel.elastic4s.requests.get.GetRequest, com.sksamuel.elastic4s.requests.get.GetResponse](com.sksamuel.elastic4s.ElasticDsl.get(DefaultOrganisationSearchEngine.this.organisationAlias, organisationId.value))(com.sksamuel.elastic4s.ElasticDsl.GetHandler, scala.concurrent.ExecutionContext.Implicits.global, scala.reflect.ManifestFactory.classType[com.sksamuel.elastic4s.requests.get.GetResponse](classOf[com.sksamuel.elastic4s.requests.get.GetResponse])).map[Option[org.make.core.user.indexed.IndexedOrganisation]](((x$1: com.sksamuel.elastic4s.requests.get.GetResponse) => x$1.toOpt[org.make.core.user.indexed.IndexedOrganisation](com.sksamuel.elastic4s.circe.`package`.hitReaderWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.decoder))))(scala.concurrent.ExecutionContext.Implicits.global)
76 8568 3302 - 3302 Select org.make.core.user.indexed.IndexedOrganisation.decoder indexed.this.IndexedOrganisation.decoder
76 8227 3302 - 3302 ApplyToImplicitArgs com.sksamuel.elastic4s.circe.hitReaderWithCirce com.sksamuel.elastic4s.circe.`package`.hitReaderWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.decoder)
80 8131 3445 - 3445 Select org.make.core.user.OrganisationSearchQuery.apply$default$4 org.scalatest.testsuite org.make.core.user.OrganisationSearchQuery.apply$default$4
80 7948 3445 - 3445 Select org.make.core.user.OrganisationSearchQuery.apply$default$5 org.scalatest.testsuite org.make.core.user.OrganisationSearchQuery.apply$default$5
80 8238 3445 - 3607 Apply org.make.core.user.OrganisationSearchQuery.apply org.scalatest.testsuite org.make.core.user.OrganisationSearchQuery.apply({ <artifact> val x$1: Some[org.make.core.user.SlugSearchFilter] @scala.reflect.internal.annotations.uncheckedBounds = scala.Some.apply[org.make.core.user.SlugSearchFilter](org.make.core.user.SlugSearchFilter.apply(slug)); <artifact> val x$2: Option[org.make.core.user.OrganisationIdsSearchFilter] @scala.reflect.internal.annotations.uncheckedBounds = org.make.core.user.OrganisationSearchFilters.parse$default$1; <artifact> val x$3: Option[org.make.core.user.OrganisationNameSearchFilter] @scala.reflect.internal.annotations.uncheckedBounds = org.make.core.user.OrganisationSearchFilters.parse$default$2; <artifact> val x$4: Option[org.make.core.user.DescriptionSearchFilter] @scala.reflect.internal.annotations.uncheckedBounds = org.make.core.user.OrganisationSearchFilters.parse$default$4; <artifact> val x$5: Option[org.make.core.user.CountrySearchFilter] @scala.reflect.internal.annotations.uncheckedBounds = org.make.core.user.OrganisationSearchFilters.parse$default$5; <artifact> val x$6: Option[org.make.core.user.LanguageSearchFilter] @scala.reflect.internal.annotations.uncheckedBounds = org.make.core.user.OrganisationSearchFilters.parse$default$6; org.make.core.user.OrganisationSearchFilters.parse(x$2, x$3, x$1, x$4, x$5, x$6) }, scala.Some.apply[org.make.core.technical.Pagination.Limit](org.make.core.technical.Pagination.Limit.apply(1)), org.make.core.user.OrganisationSearchQuery.apply$default$3, org.make.core.user.OrganisationSearchQuery.apply$default$4, org.make.core.user.OrganisationSearchQuery.apply$default$5, org.make.core.user.OrganisationSearchQuery.apply$default$6)
80 8549 3445 - 3445 Select org.make.core.user.OrganisationSearchQuery.apply$default$3 org.scalatest.testsuite org.make.core.user.OrganisationSearchQuery.apply$default$3
80 8601 3445 - 3445 Select org.make.core.user.OrganisationSearchQuery.apply$default$6 org.scalatest.testsuite org.make.core.user.OrganisationSearchQuery.apply$default$6
81 8436 3488 - 3556 Apply org.make.core.user.OrganisationSearchFilters.parse org.scalatest.testsuite org.make.core.user.OrganisationSearchFilters.parse(x$2, x$3, x$1, x$4, x$5, x$6)
81 8504 3527 - 3555 Apply scala.Some.apply org.scalatest.testsuite scala.Some.apply[org.make.core.user.SlugSearchFilter](org.make.core.user.SlugSearchFilter.apply(slug))
81 8817 3514 - 3514 Select org.make.core.user.OrganisationSearchFilters.parse$default$6 org.scalatest.testsuite org.make.core.user.OrganisationSearchFilters.parse$default$6
81 8126 3514 - 3514 Select org.make.core.user.OrganisationSearchFilters.parse$default$1 org.scalatest.testsuite org.make.core.user.OrganisationSearchFilters.parse$default$1
81 7961 3514 - 3514 Select org.make.core.user.OrganisationSearchFilters.parse$default$2 org.scalatest.testsuite org.make.core.user.OrganisationSearchFilters.parse$default$2
81 7892 3532 - 3554 Apply org.make.core.user.SlugSearchFilter.apply org.scalatest.testsuite org.make.core.user.SlugSearchFilter.apply(slug)
81 8236 3514 - 3514 Select org.make.core.user.OrganisationSearchFilters.parse$default$5 org.scalatest.testsuite org.make.core.user.OrganisationSearchFilters.parse$default$5
81 8559 3514 - 3514 Select org.make.core.user.OrganisationSearchFilters.parse$default$4 org.scalatest.testsuite org.make.core.user.OrganisationSearchFilters.parse$default$4
82 7894 3574 - 3599 Apply scala.Some.apply org.scalatest.testsuite scala.Some.apply[org.make.core.technical.Pagination.Limit](org.make.core.technical.Pagination.Limit.apply(1))
82 8279 3579 - 3598 Apply org.make.core.technical.Pagination.Limit.apply org.scalatest.testsuite org.make.core.technical.Pagination.Limit.apply(1)
84 8854 3634 - 3695 Apply org.make.core.user.OrganisationSearchFilters.getOrganisationSearchFilters org.scalatest.testsuite org.make.core.user.OrganisationSearchFilters.getOrganisationSearchFilters(query)
89 8465 3716 - 3852 Apply com.sksamuel.elastic4s.requests.searches.SearchRequest.trackTotalHits org.scalatest.testsuite com.sksamuel.elastic4s.ElasticDsl.search(DefaultOrganisationSearchEngine.this.organisationAlias).bool({ <artifact> val x$7: Seq[com.sksamuel.elastic4s.requests.searches.queries.Query] @scala.reflect.internal.annotations.uncheckedBounds = searchFilters; <artifact> val x$8: Option[Boolean] @scala.reflect.internal.annotations.uncheckedBounds = com.sksamuel.elastic4s.requests.searches.queries.compound.BoolQuery.apply$default$1; <artifact> val x$9: Option[Double] @scala.reflect.internal.annotations.uncheckedBounds = com.sksamuel.elastic4s.requests.searches.queries.compound.BoolQuery.apply$default$2; <artifact> val x$10: Option[String] @scala.reflect.internal.annotations.uncheckedBounds = com.sksamuel.elastic4s.requests.searches.queries.compound.BoolQuery.apply$default$3; <artifact> val x$11: Option[String] @scala.reflect.internal.annotations.uncheckedBounds = com.sksamuel.elastic4s.requests.searches.queries.compound.BoolQuery.apply$default$4; <artifact> val x$12: Seq[com.sksamuel.elastic4s.requests.searches.queries.Query] @scala.reflect.internal.annotations.uncheckedBounds = com.sksamuel.elastic4s.requests.searches.queries.compound.BoolQuery.apply$default$5; <artifact> val x$13: Seq[com.sksamuel.elastic4s.requests.searches.queries.Query] @scala.reflect.internal.annotations.uncheckedBounds = com.sksamuel.elastic4s.requests.searches.queries.compound.BoolQuery.apply$default$7; <artifact> val x$14: Seq[com.sksamuel.elastic4s.requests.searches.queries.Query] @scala.reflect.internal.annotations.uncheckedBounds = com.sksamuel.elastic4s.requests.searches.queries.compound.BoolQuery.apply$default$8; com.sksamuel.elastic4s.requests.searches.queries.compound.BoolQuery.apply(x$8, x$9, x$10, x$11, x$12, x$7, x$13, x$14) }).from(0).size(1).trackTotalHits(true)
91 8259 3883 - 3883 Select com.sksamuel.elastic4s.requests.searches.SearchHandlers.SearchHandler org.scalatest.testsuite com.sksamuel.elastic4s.ElasticDsl.SearchHandler
91 7887 3883 - 3883 Select scala.concurrent.ExecutionContext.Implicits.global org.scalatest.testsuite scala.concurrent.ExecutionContext.Implicits.global
91 8553 3883 - 3883 Apply scala.reflect.ManifestFactory.classType org.scalatest.testsuite scala.reflect.ManifestFactory.classType[com.sksamuel.elastic4s.requests.searches.SearchResponse](classOf[com.sksamuel.elastic4s.requests.searches.SearchResponse])
93 8603 3913 - 3938 ApplyToImplicitArgs com.sksamuel.elastic4s.requests.searches.SearchResponse.to x$2.to[org.make.core.user.indexed.IndexedOrganisation](com.sksamuel.elastic4s.circe.`package`.hitReaderWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.decoder), (ClassTag.apply[org.make.core.user.indexed.IndexedOrganisation](classOf[org.make.core.user.indexed.IndexedOrganisation]): scala.reflect.ClassTag[org.make.core.user.indexed.IndexedOrganisation]))
93 8860 3944 - 3956 Select scala.collection.IndexedSeqOps.headOption x$3.headOption
93 8175 3917 - 3917 Select org.make.core.user.indexed.IndexedOrganisation.decoder indexed.this.IndexedOrganisation.decoder
93 8261 3860 - 3957 ApplyToImplicitArgs scala.concurrent.Future.map org.scalatest.testsuite org.make.api.technical.elasticsearch.`package`.RichHttpClient(DefaultOrganisationSearchEngine.this.client).executeAsFuture[com.sksamuel.elastic4s.requests.searches.SearchRequest, com.sksamuel.elastic4s.requests.searches.SearchResponse](request)(com.sksamuel.elastic4s.ElasticDsl.SearchHandler, scala.concurrent.ExecutionContext.Implicits.global, scala.reflect.ManifestFactory.classType[com.sksamuel.elastic4s.requests.searches.SearchResponse](classOf[com.sksamuel.elastic4s.requests.searches.SearchResponse])).map[IndexedSeq[org.make.core.user.indexed.IndexedOrganisation]](((x$2: com.sksamuel.elastic4s.requests.searches.SearchResponse) => x$2.to[org.make.core.user.indexed.IndexedOrganisation](com.sksamuel.elastic4s.circe.`package`.hitReaderWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.decoder), (ClassTag.apply[org.make.core.user.indexed.IndexedOrganisation](classOf[org.make.core.user.indexed.IndexedOrganisation]): scala.reflect.ClassTag[org.make.core.user.indexed.IndexedOrganisation]))))(scala.concurrent.ExecutionContext.Implicits.global).map[Option[org.make.core.user.indexed.IndexedOrganisation]](((x$3: IndexedSeq[org.make.core.user.indexed.IndexedOrganisation]) => x$3.headOption))(scala.concurrent.ExecutionContext.Implicits.global)
93 8210 3912 - 3912 Select scala.concurrent.ExecutionContext.Implicits.global org.scalatest.testsuite scala.concurrent.ExecutionContext.Implicits.global
93 8781 3917 - 3917 ApplyToImplicitArgs com.sksamuel.elastic4s.circe.hitReaderWithCirce com.sksamuel.elastic4s.circe.`package`.hitReaderWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.decoder)
93 8452 3943 - 3943 Select scala.concurrent.ExecutionContext.Implicits.global org.scalatest.testsuite scala.concurrent.ExecutionContext.Implicits.global
97 7890 4098 - 4159 Apply org.make.core.user.OrganisationSearchFilters.getOrganisationSearchFilters org.scalatest.testsuite org.make.core.user.OrganisationSearchFilters.getOrganisationSearchFilters(query)
103 8530 4195 - 4487 Apply com.sksamuel.elastic4s.requests.searches.SearchRequest.trackTotalHits org.scalatest.testsuite com.sksamuel.elastic4s.ElasticDsl.search(DefaultOrganisationSearchEngine.this.organisationAlias).bool({ <artifact> val x$1: Seq[com.sksamuel.elastic4s.requests.searches.queries.Query] @scala.reflect.internal.annotations.uncheckedBounds = searchFilters; <artifact> val x$2: Option[Boolean] @scala.reflect.internal.annotations.uncheckedBounds = com.sksamuel.elastic4s.requests.searches.queries.compound.BoolQuery.apply$default$1; <artifact> val x$3: Option[Double] @scala.reflect.internal.annotations.uncheckedBounds = com.sksamuel.elastic4s.requests.searches.queries.compound.BoolQuery.apply$default$2; <artifact> val x$4: Option[String] @scala.reflect.internal.annotations.uncheckedBounds = com.sksamuel.elastic4s.requests.searches.queries.compound.BoolQuery.apply$default$3; <artifact> val x$5: Option[String] @scala.reflect.internal.annotations.uncheckedBounds = com.sksamuel.elastic4s.requests.searches.queries.compound.BoolQuery.apply$default$4; <artifact> val x$6: Seq[com.sksamuel.elastic4s.requests.searches.queries.Query] @scala.reflect.internal.annotations.uncheckedBounds = com.sksamuel.elastic4s.requests.searches.queries.compound.BoolQuery.apply$default$5; <artifact> val x$7: Seq[com.sksamuel.elastic4s.requests.searches.queries.Query] @scala.reflect.internal.annotations.uncheckedBounds = com.sksamuel.elastic4s.requests.searches.queries.compound.BoolQuery.apply$default$7; <artifact> val x$8: Seq[com.sksamuel.elastic4s.requests.searches.queries.Query] @scala.reflect.internal.annotations.uncheckedBounds = com.sksamuel.elastic4s.requests.searches.queries.compound.BoolQuery.apply$default$8; com.sksamuel.elastic4s.requests.searches.queries.compound.BoolQuery.apply(x$2, x$3, x$4, x$5, x$6, x$1, x$7, x$8) }).sortBy(org.make.core.user.OrganisationSearchFilters.getSort(query).toList).size(org.make.core.user.OrganisationSearchFilters.getLimitSearch(query)).from(org.make.core.user.OrganisationSearchFilters.getSkipSearch(query)).trackTotalHits(true)
105 8147 4515 - 4534 Select org.make.core.user.OrganisationSearchQuery.sortAlgorithm org.scalatest.testsuite query.sortAlgorithm
107 8786 4623 - 4660 Apply org.make.core.user.OrganisationSortAlgorithm.sortDefinition org.scalatest.testsuite sortAlgorithm.sortDefinition(request)
111 8833 4707 - 4707 Apply scala.reflect.ManifestFactory.classType org.scalatest.testsuite scala.reflect.ManifestFactory.classType[com.sksamuel.elastic4s.requests.searches.SearchResponse](classOf[com.sksamuel.elastic4s.requests.searches.SearchResponse])
111 8558 4707 - 4707 Select com.sksamuel.elastic4s.requests.searches.SearchHandlers.SearchHandler org.scalatest.testsuite com.sksamuel.elastic4s.ElasticDsl.SearchHandler
111 8213 4707 - 4707 Select scala.concurrent.ExecutionContext.Implicits.global org.scalatest.testsuite scala.concurrent.ExecutionContext.Implicits.global
112 8767 4736 - 4736 Select scala.concurrent.ExecutionContext.Implicits.global org.scalatest.testsuite scala.concurrent.ExecutionContext.Implicits.global
112 8560 4676 - 4866 ApplyToImplicitArgs scala.concurrent.Future.map org.scalatest.testsuite org.make.api.technical.elasticsearch.`package`.RichHttpClient(DefaultOrganisationSearchEngine.this.client).executeAsFuture[com.sksamuel.elastic4s.requests.searches.SearchRequest, com.sksamuel.elastic4s.requests.searches.SearchResponse](requestSorted)(com.sksamuel.elastic4s.ElasticDsl.SearchHandler, scala.concurrent.ExecutionContext.Implicits.global, scala.reflect.ManifestFactory.classType[com.sksamuel.elastic4s.requests.searches.SearchResponse](classOf[com.sksamuel.elastic4s.requests.searches.SearchResponse])).map[org.make.core.user.indexed.OrganisationSearchResult](((response: com.sksamuel.elastic4s.requests.searches.SearchResponse) => org.make.core.user.indexed.OrganisationSearchResult.apply(response.totalHits, response.to[org.make.core.user.indexed.IndexedOrganisation](com.sksamuel.elastic4s.circe.`package`.hitReaderWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.decoder), (ClassTag.apply[org.make.core.user.indexed.IndexedOrganisation](classOf[org.make.core.user.indexed.IndexedOrganisation]): scala.reflect.ClassTag[org.make.core.user.indexed.IndexedOrganisation])))))(scala.concurrent.ExecutionContext.Implicits.global)
113 8262 4834 - 4834 Select org.make.core.user.indexed.IndexedOrganisation.decoder indexed.this.IndexedOrganisation.decoder
113 7876 4834 - 4834 ApplyToImplicitArgs com.sksamuel.elastic4s.circe.hitReaderWithCirce com.sksamuel.elastic4s.circe.`package`.hitReaderWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.decoder)
113 8168 4760 - 4856 Apply org.make.core.user.indexed.OrganisationSearchResult.apply org.make.core.user.indexed.OrganisationSearchResult.apply(response.totalHits, response.to[org.make.core.user.indexed.IndexedOrganisation](com.sksamuel.elastic4s.circe.`package`.hitReaderWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.decoder), (ClassTag.apply[org.make.core.user.indexed.IndexedOrganisation](classOf[org.make.core.user.indexed.IndexedOrganisation]): scala.reflect.ClassTag[org.make.core.user.indexed.IndexedOrganisation])))
113 8455 4793 - 4811 Select com.sksamuel.elastic4s.requests.searches.SearchResponse.totalHits response.totalHits
113 8532 4823 - 4855 ApplyToImplicitArgs com.sksamuel.elastic4s.requests.searches.SearchResponse.to response.to[org.make.core.user.indexed.IndexedOrganisation](com.sksamuel.elastic4s.circe.`package`.hitReaderWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.decoder), (ClassTag.apply[org.make.core.user.indexed.IndexedOrganisation](classOf[org.make.core.user.indexed.IndexedOrganisation]): scala.reflect.ClassTag[org.make.core.user.indexed.IndexedOrganisation]))
118 8853 5001 - 5040 Apply scala.Option.getOrElse mayBeIndex.getOrElse[com.sksamuel.elastic4s.Index](DefaultOrganisationSearchEngine.this.organisationAlias)
118 8192 5022 - 5039 Select org.make.api.organisation.DefaultOrganisationSearchEngineComponent.DefaultOrganisationSearchEngine.organisationAlias DefaultOrganisationSearchEngine.this.organisationAlias
120 8104 5078 - 5078 Select scala.concurrent.ExecutionContext.Implicits.global scala.concurrent.ExecutionContext.Implicits.global
120 8858 5078 - 5078 Apply scala.reflect.ManifestFactory.classType scala.reflect.ManifestFactory.classType[com.sksamuel.elastic4s.requests.indexes.IndexResponse](classOf[com.sksamuel.elastic4s.requests.indexes.IndexResponse])
120 8439 5099 - 5099 Select org.make.core.user.indexed.IndexedOrganisation.encoder indexed.this.IndexedOrganisation.encoder
120 8172 5144 - 5171 Select org.make.core.user.UserId.value record.organisationId.value
120 8746 5079 - 5172 Apply com.sksamuel.elastic4s.requests.indexes.IndexRequest.id com.sksamuel.elastic4s.ElasticDsl.indexInto(index).doc[org.make.core.user.indexed.IndexedOrganisation](record)(com.sksamuel.elastic4s.circe.`package`.indexableWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.encoder, DefaultOrganisationSearchEngine.this.printer)).refresh(com.sksamuel.elastic4s.requests.common.RefreshPolicy.IMMEDIATE).id(record.organisationId.value)
120 8489 5047 - 5173 ApplyToImplicitArgs org.make.api.technical.elasticsearch.RichHttpClient.executeAsFuture org.make.api.technical.elasticsearch.`package`.RichHttpClient(DefaultOrganisationSearchEngine.this.client).executeAsFuture[com.sksamuel.elastic4s.requests.indexes.IndexRequest, com.sksamuel.elastic4s.requests.indexes.IndexResponse](com.sksamuel.elastic4s.ElasticDsl.indexInto(index).doc[org.make.core.user.indexed.IndexedOrganisation](record)(com.sksamuel.elastic4s.circe.`package`.indexableWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.encoder, DefaultOrganisationSearchEngine.this.printer)).refresh(com.sksamuel.elastic4s.requests.common.RefreshPolicy.IMMEDIATE).id(record.organisationId.value))(com.sksamuel.elastic4s.ElasticDsl.IndexHandler, scala.concurrent.ExecutionContext.Implicits.global, scala.reflect.ManifestFactory.classType[com.sksamuel.elastic4s.requests.indexes.IndexResponse](classOf[com.sksamuel.elastic4s.requests.indexes.IndexResponse]))
120 7929 5078 - 5078 ApplyToImplicitArgs cats.instances.FutureInstances.catsStdInstancesForFuture cats.implicits.catsStdInstancesForFuture(scala.concurrent.ExecutionContext.Implicits.global)
120 7878 5099 - 5099 ApplyToImplicitArgs com.sksamuel.elastic4s.circe.indexableWithCirce com.sksamuel.elastic4s.circe.`package`.indexableWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.encoder, DefaultOrganisationSearchEngine.this.printer)
120 8614 5078 - 5078 Select com.sksamuel.elastic4s.handlers.index.IndexHandlers.IndexHandler com.sksamuel.elastic4s.ElasticDsl.IndexHandler
120 8195 5078 - 5078 Select scala.concurrent.ExecutionContext.Implicits.global scala.concurrent.ExecutionContext.Implicits.global
120 8090 5099 - 5099 Select org.make.api.organisation.DefaultOrganisationSearchEngineComponent.DefaultOrganisationSearchEngine.printer DefaultOrganisationSearchEngine.this.printer
120 8512 5116 - 5139 Select com.sksamuel.elastic4s.requests.common.RefreshPolicy.IMMEDIATE com.sksamuel.elastic4s.requests.common.RefreshPolicy.IMMEDIATE
121 8543 5186 - 5190 Select akka.Done akka.Done
121 8178 5047 - 5191 Apply cats.Functor.Ops.as cats.implicits.toFunctorOps[scala.concurrent.Future, com.sksamuel.elastic4s.requests.indexes.IndexResponse](org.make.api.technical.elasticsearch.`package`.RichHttpClient(DefaultOrganisationSearchEngine.this.client).executeAsFuture[com.sksamuel.elastic4s.requests.indexes.IndexRequest, com.sksamuel.elastic4s.requests.indexes.IndexResponse](com.sksamuel.elastic4s.ElasticDsl.indexInto(index).doc[org.make.core.user.indexed.IndexedOrganisation](record)(com.sksamuel.elastic4s.circe.`package`.indexableWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.encoder, DefaultOrganisationSearchEngine.this.printer)).refresh(com.sksamuel.elastic4s.requests.common.RefreshPolicy.IMMEDIATE).id(record.organisationId.value))(com.sksamuel.elastic4s.ElasticDsl.IndexHandler, scala.concurrent.ExecutionContext.Implicits.global, scala.reflect.ManifestFactory.classType[com.sksamuel.elastic4s.requests.indexes.IndexResponse](classOf[com.sksamuel.elastic4s.requests.indexes.IndexResponse])))(cats.implicits.catsStdInstancesForFuture(scala.concurrent.ExecutionContext.Implicits.global)).as[akka.Done.type](akka.Done)
125 8421 5333 - 5372 Apply scala.Option.getOrElse mayBeIndex.getOrElse[com.sksamuel.elastic4s.Index](DefaultOrganisationSearchEngine.this.organisationAlias)
125 8802 5354 - 5371 Select org.make.api.organisation.DefaultOrganisationSearchEngineComponent.DefaultOrganisationSearchEngine.organisationAlias DefaultOrganisationSearchEngine.this.organisationAlias
127 8089 5410 - 5410 Select scala.concurrent.ExecutionContext.Implicits.global scala.concurrent.ExecutionContext.Implicits.global
127 8475 5379 - 5555 ApplyToImplicitArgs org.make.api.technical.elasticsearch.RichHttpClient.executeAsFuture org.make.api.technical.elasticsearch.`package`.RichHttpClient(DefaultOrganisationSearchEngine.this.client).executeAsFuture[com.sksamuel.elastic4s.requests.bulk.BulkRequest, com.sksamuel.elastic4s.requests.bulk.BulkResponse](com.sksamuel.elastic4s.ElasticDsl.bulk(records.map[com.sksamuel.elastic4s.requests.indexes.IndexRequest](((record: org.make.core.user.indexed.IndexedOrganisation) => com.sksamuel.elastic4s.ElasticDsl.indexInto(index).doc[org.make.core.user.indexed.IndexedOrganisation](record)(com.sksamuel.elastic4s.circe.`package`.indexableWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.encoder, DefaultOrganisationSearchEngine.this.printer)).refresh(com.sksamuel.elastic4s.requests.common.RefreshPolicy.IMMEDIATE).id(record.organisationId.value)))))(com.sksamuel.elastic4s.ElasticDsl.BulkHandler, scala.concurrent.ExecutionContext.Implicits.global, scala.reflect.ManifestFactory.classType[com.sksamuel.elastic4s.requests.bulk.BulkResponse](classOf[com.sksamuel.elastic4s.requests.bulk.BulkResponse]))
127 8848 5410 - 5410 Apply scala.reflect.ManifestFactory.classType scala.reflect.ManifestFactory.classType[com.sksamuel.elastic4s.requests.bulk.BulkResponse](classOf[com.sksamuel.elastic4s.requests.bulk.BulkResponse])
127 8764 5411 - 5554 Apply com.sksamuel.elastic4s.api.BulkApi.bulk com.sksamuel.elastic4s.ElasticDsl.bulk(records.map[com.sksamuel.elastic4s.requests.indexes.IndexRequest](((record: org.make.core.user.indexed.IndexedOrganisation) => com.sksamuel.elastic4s.ElasticDsl.indexInto(index).doc[org.make.core.user.indexed.IndexedOrganisation](record)(com.sksamuel.elastic4s.circe.`package`.indexableWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.encoder, DefaultOrganisationSearchEngine.this.printer)).refresh(com.sksamuel.elastic4s.requests.common.RefreshPolicy.IMMEDIATE).id(record.organisationId.value))))
127 7893 5410 - 5410 ApplyToImplicitArgs cats.instances.FutureInstances.catsStdInstancesForFuture cats.implicits.catsStdInstancesForFuture(scala.concurrent.ExecutionContext.Implicits.global)
127 8404 5410 - 5410 Select com.sksamuel.elastic4s.handlers.bulk.BulkHandlers.BulkHandler com.sksamuel.elastic4s.ElasticDsl.BulkHandler
127 8162 5416 - 5553 Apply scala.collection.IterableOps.map records.map[com.sksamuel.elastic4s.requests.indexes.IndexRequest](((record: org.make.core.user.indexed.IndexedOrganisation) => com.sksamuel.elastic4s.ElasticDsl.indexInto(index).doc[org.make.core.user.indexed.IndexedOrganisation](record)(com.sksamuel.elastic4s.circe.`package`.indexableWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.encoder, DefaultOrganisationSearchEngine.this.printer)).refresh(com.sksamuel.elastic4s.requests.common.RefreshPolicy.IMMEDIATE).id(record.organisationId.value)))
127 8191 5410 - 5410 Select scala.concurrent.ExecutionContext.Implicits.global scala.concurrent.ExecutionContext.Implicits.global
128 8086 5487 - 5510 Select com.sksamuel.elastic4s.requests.common.RefreshPolicy.IMMEDIATE com.sksamuel.elastic4s.requests.common.RefreshPolicy.IMMEDIATE
128 8492 5470 - 5470 ApplyToImplicitArgs com.sksamuel.elastic4s.circe.indexableWithCirce com.sksamuel.elastic4s.circe.`package`.indexableWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.encoder, DefaultOrganisationSearchEngine.this.printer)
128 7911 5515 - 5542 Select org.make.core.user.UserId.value record.organisationId.value
128 8240 5470 - 5470 Select org.make.core.user.indexed.IndexedOrganisation.encoder indexed.this.IndexedOrganisation.encoder
128 8544 5450 - 5543 Apply com.sksamuel.elastic4s.requests.indexes.IndexRequest.id com.sksamuel.elastic4s.ElasticDsl.indexInto(index).doc[org.make.core.user.indexed.IndexedOrganisation](record)(com.sksamuel.elastic4s.circe.`package`.indexableWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.encoder, DefaultOrganisationSearchEngine.this.printer)).refresh(com.sksamuel.elastic4s.requests.common.RefreshPolicy.IMMEDIATE).id(record.organisationId.value)
128 8846 5470 - 5470 Select org.make.api.organisation.DefaultOrganisationSearchEngineComponent.DefaultOrganisationSearchEngine.printer DefaultOrganisationSearchEngine.this.printer
130 8143 5379 - 5573 Apply cats.Functor.Ops.as cats.implicits.toFunctorOps[scala.concurrent.Future, com.sksamuel.elastic4s.requests.bulk.BulkResponse](org.make.api.technical.elasticsearch.`package`.RichHttpClient(DefaultOrganisationSearchEngine.this.client).executeAsFuture[com.sksamuel.elastic4s.requests.bulk.BulkRequest, com.sksamuel.elastic4s.requests.bulk.BulkResponse](com.sksamuel.elastic4s.ElasticDsl.bulk(records.map[com.sksamuel.elastic4s.requests.indexes.IndexRequest](((record: org.make.core.user.indexed.IndexedOrganisation) => com.sksamuel.elastic4s.ElasticDsl.indexInto(index).doc[org.make.core.user.indexed.IndexedOrganisation](record)(com.sksamuel.elastic4s.circe.`package`.indexableWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.encoder, DefaultOrganisationSearchEngine.this.printer)).refresh(com.sksamuel.elastic4s.requests.common.RefreshPolicy.IMMEDIATE).id(record.organisationId.value)))))(com.sksamuel.elastic4s.ElasticDsl.BulkHandler, scala.concurrent.ExecutionContext.Implicits.global, scala.reflect.ManifestFactory.classType[com.sksamuel.elastic4s.requests.bulk.BulkResponse](classOf[com.sksamuel.elastic4s.requests.bulk.BulkResponse])))(cats.implicits.catsStdInstancesForFuture(scala.concurrent.ExecutionContext.Implicits.global)).as[akka.Done.type](akka.Done)
130 8510 5568 - 5572 Select akka.Done akka.Done
134 8751 5730 - 5747 Select org.make.api.organisation.DefaultOrganisationSearchEngineComponent.DefaultOrganisationSearchEngine.organisationAlias DefaultOrganisationSearchEngine.this.organisationAlias
134 8407 5709 - 5748 Apply scala.Option.getOrElse mayBeIndex.getOrElse[com.sksamuel.elastic4s.Index](DefaultOrganisationSearchEngine.this.organisationAlias)
136 8134 5786 - 5786 Select com.sksamuel.elastic4s.handlers.update.UpdateHandlers.UpdateHandler com.sksamuel.elastic4s.ElasticDsl.UpdateHandler
136 8824 5786 - 5786 Select scala.concurrent.ExecutionContext.Implicits.global scala.concurrent.ExecutionContext.Implicits.global
136 8411 5786 - 5786 Apply scala.reflect.ManifestFactory.classType scala.reflect.ManifestFactory.classType[com.sksamuel.elastic4s.requests.update.UpdateResponse](classOf[com.sksamuel.elastic4s.requests.update.UpdateResponse])
136 8470 5786 - 5786 ApplyToImplicitArgs cats.instances.FutureInstances.catsStdInstancesForFuture cats.implicits.catsStdInstancesForFuture(scala.concurrent.ExecutionContext.Implicits.global)
136 8799 5786 - 5786 Select scala.concurrent.ExecutionContext.Implicits.global scala.concurrent.ExecutionContext.Implicits.global
136 8239 5755 - 5925 ApplyToImplicitArgs org.make.api.technical.elasticsearch.RichHttpClient.executeAsFuture org.make.api.technical.elasticsearch.`package`.RichHttpClient(DefaultOrganisationSearchEngine.this.client).executeAsFuture[com.sksamuel.elastic4s.requests.update.UpdateRequest, com.sksamuel.elastic4s.requests.update.UpdateResponse](com.sksamuel.elastic4s.ElasticDsl.updateById(index, record.organisationId.value).doc[org.make.core.user.indexed.IndexedOrganisation](record)(com.sksamuel.elastic4s.circe.`package`.indexableWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.encoder, DefaultOrganisationSearchEngine.this.printer)).refresh(com.sksamuel.elastic4s.requests.common.RefreshPolicy.IMMEDIATE))(com.sksamuel.elastic4s.ElasticDsl.UpdateHandler, scala.concurrent.ExecutionContext.Implicits.global, scala.reflect.ManifestFactory.classType[com.sksamuel.elastic4s.requests.update.UpdateResponse](classOf[com.sksamuel.elastic4s.requests.update.UpdateResponse]))
137 8194 5816 - 5843 Select org.make.core.user.UserId.value record.organisationId.value
138 8821 5861 - 5861 Select org.make.core.user.indexed.IndexedOrganisation.encoder indexed.this.IndexedOrganisation.encoder
138 8488 5861 - 5861 Select org.make.api.organisation.DefaultOrganisationSearchEngineComponent.DefaultOrganisationSearchEngine.printer DefaultOrganisationSearchEngine.this.printer
138 8069 5861 - 5861 ApplyToImplicitArgs com.sksamuel.elastic4s.circe.indexableWithCirce com.sksamuel.elastic4s.circe.`package`.indexableWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.encoder, DefaultOrganisationSearchEngine.this.printer)
139 8513 5798 - 5915 Apply com.sksamuel.elastic4s.requests.update.UpdateRequest.refresh com.sksamuel.elastic4s.ElasticDsl.updateById(index, record.organisationId.value).doc[org.make.core.user.indexed.IndexedOrganisation](record)(com.sksamuel.elastic4s.circe.`package`.indexableWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.encoder, DefaultOrganisationSearchEngine.this.printer)).refresh(com.sksamuel.elastic4s.requests.common.RefreshPolicy.IMMEDIATE)
139 8685 5891 - 5914 Select com.sksamuel.elastic4s.requests.common.RefreshPolicy.IMMEDIATE com.sksamuel.elastic4s.requests.common.RefreshPolicy.IMMEDIATE
141 8116 5938 - 5942 Select akka.Done akka.Done
141 8688 5755 - 5943 Apply cats.Functor.Ops.as cats.implicits.toFunctorOps[scala.concurrent.Future, com.sksamuel.elastic4s.requests.update.UpdateResponse](org.make.api.technical.elasticsearch.`package`.RichHttpClient(DefaultOrganisationSearchEngine.this.client).executeAsFuture[com.sksamuel.elastic4s.requests.update.UpdateRequest, com.sksamuel.elastic4s.requests.update.UpdateResponse](com.sksamuel.elastic4s.ElasticDsl.updateById(index, record.organisationId.value).doc[org.make.core.user.indexed.IndexedOrganisation](record)(com.sksamuel.elastic4s.circe.`package`.indexableWithCirce[org.make.core.user.indexed.IndexedOrganisation](indexed.this.IndexedOrganisation.encoder, DefaultOrganisationSearchEngine.this.printer)).refresh(com.sksamuel.elastic4s.requests.common.RefreshPolicy.IMMEDIATE))(com.sksamuel.elastic4s.ElasticDsl.UpdateHandler, scala.concurrent.ExecutionContext.Implicits.global, scala.reflect.ManifestFactory.classType[com.sksamuel.elastic4s.requests.update.UpdateResponse](classOf[com.sksamuel.elastic4s.requests.update.UpdateResponse])))(cats.implicits.catsStdInstancesForFuture(scala.concurrent.ExecutionContext.Implicits.global)).as[akka.Done.type](akka.Done)