New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose the indices names in every action relates to if applicable #6933
Changes from all commits
eddb909
59e7ad3
18e62a8
4f631f7
85b8ec1
fcee5fe
f11567b
d644e02
51641be
870b8ea
e81cbdd
fbe463d
ec73bba
4298a8d
dbe435b
912dac3
efa44aa
56d6fef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.action; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Needs to be implemented by all {@link org.elasticsearch.action.ActionRequest} subclasses that are composed of | ||
* multiple subrequests which relate to one or more indices. Allows to retrieve those subrequests. | ||
*/ | ||
public interface CompositeIndicesRequest { | ||
|
||
/** | ||
* Returns the subrequests that a composite request is composed of | ||
*/ | ||
List<? extends IndicesRequest> subRequests(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.action; | ||
|
||
import org.elasticsearch.action.support.IndicesOptions; | ||
|
||
/** | ||
* Needs to be implemented by all {@link org.elasticsearch.action.ActionRequest} subclasses that relate to | ||
* one or more indices. Allows to retrieve which indices the action relates to. | ||
*/ | ||
public interface IndicesRequest { | ||
|
||
/** | ||
* Returns the array of indices that the action relates to | ||
*/ | ||
String[] indices(); | ||
|
||
/** | ||
* Returns the indices options used to resolve indices. They tell for instance whether a single index is | ||
* accepted, whether an empty array will be converted to _all, and how wildcards will be expanded if needed. | ||
*/ | ||
IndicesOptions indicesOptions(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ | |
|
||
import org.elasticsearch.Version; | ||
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.action.IndicesRequest; | ||
import org.elasticsearch.action.support.IndicesOptions; | ||
import org.elasticsearch.action.support.single.custom.SingleCustomOperationRequest; | ||
import org.elasticsearch.common.Nullable; | ||
import org.elasticsearch.common.Strings; | ||
|
@@ -34,7 +36,7 @@ | |
* A request to analyze a text associated with a specific index. Allow to provide | ||
* the actual analyzer name to perform the analysis with. | ||
*/ | ||
public class AnalyzeRequest extends SingleCustomOperationRequest<AnalyzeRequest> { | ||
public class AnalyzeRequest extends SingleCustomOperationRequest<AnalyzeRequest> implements IndicesRequest { | ||
|
||
private String index; | ||
|
||
|
@@ -87,6 +89,19 @@ public String index() { | |
return this.index; | ||
} | ||
|
||
@Override | ||
public String[] indices() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we also prevent There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's ok here as the index in the analyze api is optional There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok cool |
||
if (index == null) { | ||
return Strings.EMPTY_ARRAY; | ||
} | ||
return new String[]{index}; | ||
} | ||
|
||
@Override | ||
public IndicesOptions indicesOptions() { | ||
return IndicesOptions.strictSingleIndexNoExpandForbidClosed(); | ||
} | ||
|
||
public AnalyzeRequest analyzer(String analyzer) { | ||
this.analyzer = analyzer; | ||
return this; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should put a
public static final String ALL_INDICES = "_all";
onIndicesRequest
and mention it in the error message?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This request doesn't support empty or null values (both are rejected during validation), and will never expand to
_all
. This change is just to avoid an NPE in the following loop if one doesrequest.indices(null)
. I don't think_all
is related.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok fine