Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated alias api for elastic 1.0ec1

  • Loading branch information...
commit 728f1a96c52770a78be7dd877d81c3fa332506f5 1 parent 5c1da41
@sksamuel sksamuel authored
View
31 src/main/scala/com/sksamuel/elastic4s/AliasesDsl.scala
@@ -1,9 +1,9 @@
package com.sksamuel.elastic4s
-import org.elasticsearch.action.admin.indices.alias.{IndicesAliasesAction, IndicesAliasesRequest}
import org.elasticsearch.index.query.FilterBuilder
import org.elasticsearch.cluster.metadata.AliasAction
-import org.elasticsearch.action.admin.indices.alias.get.{IndicesGetAliasesRequest, IndicesGetAliasesAction}
+import org.elasticsearch.action.admin.indices.alias.get.{GetAliasesAction, GetAliasesRequest}
+import org.elasticsearch.action.admin.indices.alias.{IndicesAliasesRequest, IndicesAliasesAction}
trait AliasesDsl {
def aliases = new AliasesExpectsAction
@@ -11,29 +11,30 @@ trait AliasesDsl {
class AliasesExpectsAction {
def add(alias: String) = new AddAliasExpectsIndex(alias)
def remove(alias: String) = new RemoveAliasExpectsIndex(alias)
- def get(alias: String*) = new AliasQueryDefinition(new IndicesGetAliasesRequest(alias.toArray))
+ def get(aliases: String*) = new GetAliasExpectsIndex(aliases)
}
class AddAliasExpectsIndex(alias: String) {
- def on(index: String) = new AliasDefinition(new AliasAction(AliasAction.Type.ADD, index, alias))
+ def on(index: String) = new MutateAliasDefinition(new AliasAction(AliasAction.Type.ADD, index, alias))
}
class RemoveAliasExpectsIndex(alias: String) {
- def on(index: String) = new AliasDefinition(new AliasAction(AliasAction.Type.REMOVE, index, alias))
+ def on(index: String) = new MutateAliasDefinition(new AliasAction(AliasAction.Type.REMOVE, index, alias))
}
- class AliasDefinition(aliasAction: AliasAction) extends IndicesRequestDefinition(IndicesAliasesAction.INSTANCE) {
- def routing(route: String) = new AliasDefinition(aliasAction.routing(route))
-
- def filter(filter: FilterBuilder) = new AliasDefinition(aliasAction.filter(filter))
-
- def build = new IndicesAliasesRequest().addAliasAction(aliasAction)
+ class GetAliasExpectsIndex(aliases: Seq[String]) {
+ def on(indexes: String*) = new GetAliasDefinition(aliases)
}
- class AliasQueryDefinition(request: IndicesGetAliasesRequest) extends IndicesRequestDefinition(IndicesGetAliasesAction.INSTANCE) {
-
- def on(indices: String*) = new AliasQueryDefinition(request.indices(indices:_*))
+ class GetAliasDefinition(aliases: Seq[String], indexes: String*)
+ extends IndicesRequestDefinition(GetAliasesAction.INSTANCE) {
+ val build = new GetAliasesRequest(aliases.toArray).indices(indexes: _*)
+ }
- def build = request
+ class MutateAliasDefinition(aliasAction: AliasAction)
+ extends IndicesRequestDefinition(IndicesAliasesAction.INSTANCE) {
+ def routing(route: String) = new MutateAliasDefinition(aliasAction.routing(route))
+ def filter(filter: FilterBuilder) = new MutateAliasDefinition(aliasAction.filter(filter))
+ def build = new IndicesAliasesRequest().addAliasAction(aliasAction)
}
}
View
7 src/main/scala/com/sksamuel/elastic4s/RequestDefinition.scala
@@ -2,9 +2,6 @@ package com.sksamuel.elastic4s
import org.elasticsearch.action._
import org.elasticsearch.action.admin.indices.IndicesAction
-import org.elasticsearch.action.bulk.{BulkRequestBuilder, BulkAction}
-import ElasticDsl._
-
sealed trait RequestDefinitionLike[Req <: ActionRequest[Req], Res <: ActionResponse, Builder <: ActionRequestBuilder[Req, Res, Builder]] {
def action: GenericAction[Req, Res]
@@ -12,7 +9,7 @@ sealed trait RequestDefinitionLike[Req <: ActionRequest[Req], Res <: ActionRespo
}
abstract class RequestDefinition[Req <: ActionRequest[Req], Res <: ActionResponse, Builder <: ActionRequestBuilder[Req, Res, Builder]]
- (val action: Action[Req, Res, Builder]) extends RequestDefinitionLike[Req, Res, Builder]
+(val action: Action[Req, Res, Builder]) extends RequestDefinitionLike[Req, Res, Builder]
abstract class IndicesRequestDefinition[Req <: ActionRequest[Req], Res <: ActionResponse, Builder <: ActionRequestBuilder[Req, Res, Builder]]
- (val action: IndicesAction[Req, Res, Builder]) extends RequestDefinitionLike[Req, Res, Builder]
+(val action: IndicesAction[Req, Res, Builder]) extends RequestDefinitionLike[Req, Res, Builder]
Please sign in to comment.
Something went wrong with that request. Please try again.