-
Notifications
You must be signed in to change notification settings - Fork 691
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add reload_search_analyzers call (#3067)
- Loading branch information
Showing
6 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
elastic4s-core/src/main/scala/com/sksamuel/elastic4s/api/ReloadSearchAnalyzersApi.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.sksamuel.elastic4s.api | ||
|
||
import com.sksamuel.elastic4s.Indexes | ||
import com.sksamuel.elastic4s.requests.reloadsearchanalyzers.ReloadSearchAnalyzersRequest | ||
|
||
trait ReloadSearchAnalyzersApi { | ||
def reloadSearchAnalyzers(index: String): ReloadSearchAnalyzersRequest = ReloadSearchAnalyzersRequest(Indexes(index)) | ||
def reloadSearchAnalyzers(indexes: Indexes): ReloadSearchAnalyzersRequest = ReloadSearchAnalyzersRequest(indexes) | ||
def reloadSearchAnalyzers(indexes: Seq[String]): ReloadSearchAnalyzersRequest = ReloadSearchAnalyzersRequest(Indexes(indexes)) | ||
} |
5 changes: 5 additions & 0 deletions
5
.../com/sksamuel/elastic4s/requests/reloadsearchanalyzers/ReloadSearchAnalyzersRequest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.sksamuel.elastic4s.requests.reloadsearchanalyzers | ||
|
||
import com.sksamuel.elastic4s.Indexes | ||
|
||
case class ReloadSearchAnalyzersRequest(indexes: Indexes) extends Serializable |
9 changes: 9 additions & 0 deletions
9
...com/sksamuel/elastic4s/requests/reloadsearchanalyzers/ReloadSearchAnalyzersResponse.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.sksamuel.elastic4s.requests.reloadsearchanalyzers | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
import com.sksamuel.elastic4s.requests.common.Shards | ||
|
||
case class ReloadDetails(index: String, @JsonProperty("reloaded_analyzers") reloadedAnalyzers: Seq[String], @JsonProperty("reloaded_node_ids") reloadedNodeIds: Seq[String]) | ||
|
||
case class ReloadSearchAnalyzersResponse(@JsonProperty("reload_details") reloadDetails: Seq[ReloadDetails], | ||
@JsonProperty("_shards") shards: Option[Shards]) |
23 changes: 23 additions & 0 deletions
23
...com/sksamuel/elastic4s/handlers/reloadsearchanalyzers/ReloadSearchAnalyzersHandlers.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.sksamuel.elastic4s.handlers.reloadsearchanalyzers | ||
|
||
import com.sksamuel.elastic4s.requests.reloadsearchanalyzers._ | ||
import com.sksamuel.elastic4s.{ElasticRequest, Handler, HttpResponse, ResponseHandler} | ||
|
||
trait ReloadSearchAnalyzersHandlers { | ||
implicit object ReloadSearchAnalyzersHandler extends Handler[ReloadSearchAnalyzersRequest, ReloadSearchAnalyzersResponse] { | ||
|
||
override def responseHandler: ResponseHandler[ReloadSearchAnalyzersResponse] = new ResponseHandler[ReloadSearchAnalyzersResponse] { | ||
override def handle(response: HttpResponse): Right[Nothing, ReloadSearchAnalyzersResponse] = | ||
response.statusCode match { | ||
case 404 | 200 => Right(ResponseHandler.fromResponse[ReloadSearchAnalyzersResponse](response)) | ||
case _ => sys.error("Invalid response") | ||
} | ||
} | ||
|
||
override def build(request: ReloadSearchAnalyzersRequest): ElasticRequest = { | ||
val endpoint = s"/${request.indexes.string(true)}/_reload_search_analyzers" | ||
|
||
ElasticRequest("POST", endpoint) | ||
} | ||
} | ||
} |