Skip to content

Commit

Permalink
include aliases in rest autocompletion
Browse files Browse the repository at this point in the history
  • Loading branch information
lmenezes committed Feb 14, 2020
1 parent 444542c commit abb8ab7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/controllers/RestController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class RestController @Inject()(val authentication: AuthenticationModule,
}

def index = process { request =>
client.getClusterMapping(request.target).map {
client.getAliases(request.target).map {
case Success(status, body) =>
val data = Json.obj(
"indices" -> AutocompletionIndices(body),
Expand Down
12 changes: 8 additions & 4 deletions app/models/rest/AutocompletionIndices.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import play.api.libs.json.{JsArray, JsObject, JsString, JsValue}

object AutocompletionIndices {

def apply(mappings: JsValue): JsArray =
JsArray(mappings.as[JsObject].value.keys.map(i => JsString(i)).toSeq)

}
def apply(aliases: JsValue): JsArray =
JsArray(
aliases.as[JsObject].value.flatMap { case (idx, data) =>
(data \ "aliases").as[JsObject].keys + idx
}.toSeq.distinct.map(JsString)
)

}

0 comments on commit abb8ab7

Please sign in to comment.