Fix line length for org.elasticsearch.action.* files (#35607)
This removes the checkstyle suppressions for things in the `action` package. Relates to #34884
This commit is contained in:
parent
022726011c
commit
22933ebcd5
|
@ -45,18 +45,6 @@
|
||||||
|
|
||||||
<!-- Hopefully temporary suppression of LineLength on files that don't pass it. We should remove these when we the
|
<!-- Hopefully temporary suppression of LineLength on files that don't pass it. We should remove these when we the
|
||||||
files start to pass. -->
|
files start to pass. -->
|
||||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]search[/\\]MultiSearchRequestBuilder.java" checks="LineLength" />
|
|
||||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]search[/\\]SearchPhaseController.java" checks="LineLength" />
|
|
||||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]termvectors[/\\]MultiTermVectorsRequest.java" checks="LineLength" />
|
|
||||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]termvectors[/\\]TermVectorsRequest.java" checks="LineLength" />
|
|
||||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]termvectors[/\\]TermVectorsResponse.java" checks="LineLength" />
|
|
||||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]termvectors[/\\]TermVectorsWriter.java" checks="LineLength" />
|
|
||||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]termvectors[/\\]TransportMultiTermVectorsAction.java" checks="LineLength" />
|
|
||||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]termvectors[/\\]TransportShardMultiTermsVectorAction.java" checks="LineLength" />
|
|
||||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]termvectors[/\\]TransportTermVectorsAction.java" checks="LineLength" />
|
|
||||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]update[/\\]TransportUpdateAction.java" checks="LineLength" />
|
|
||||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]update[/\\]UpdateRequest.java" checks="LineLength" />
|
|
||||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]update[/\\]UpdateRequestBuilder.java" checks="LineLength" />
|
|
||||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]CompositeIndexEventListener.java" checks="LineLength" />
|
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]CompositeIndexEventListener.java" checks="LineLength" />
|
||||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]IndexSettings.java" checks="LineLength" />
|
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]IndexSettings.java" checks="LineLength" />
|
||||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]MergePolicyConfig.java" checks="LineLength" />
|
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]MergePolicyConfig.java" checks="LineLength" />
|
||||||
|
@ -151,13 +139,6 @@
|
||||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]snapshots[/\\]SnapshotsService.java" checks="LineLength" />
|
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]snapshots[/\\]SnapshotsService.java" checks="LineLength" />
|
||||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]threadpool[/\\]ThreadPool.java" checks="LineLength" />
|
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]threadpool[/\\]ThreadPool.java" checks="LineLength" />
|
||||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]VersionTests.java" checks="LineLength" />
|
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]VersionTests.java" checks="LineLength" />
|
||||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]RejectionActionIT.java" checks="LineLength" />
|
|
||||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]HotThreadsIT.java" checks="LineLength" />
|
|
||||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]search[/\\]SearchRequestBuilderTests.java" checks="LineLength" />
|
|
||||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]termvectors[/\\]AbstractTermVectorsTestCase.java" checks="LineLength" />
|
|
||||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]termvectors[/\\]GetTermVectorsIT.java" checks="LineLength" />
|
|
||||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]termvectors[/\\]MultiTermVectorsIT.java" checks="LineLength" />
|
|
||||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]termvectors[/\\]TermVectorsUnitTests.java" checks="LineLength" />
|
|
||||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]aliases[/\\]IndexAliasesIT.java" checks="LineLength" />
|
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]aliases[/\\]IndexAliasesIT.java" checks="LineLength" />
|
||||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]deps[/\\]joda[/\\]SimpleJodaTests.java" checks="LineLength" />
|
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]deps[/\\]joda[/\\]SimpleJodaTests.java" checks="LineLength" />
|
||||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]env[/\\]EnvironmentTests.java" checks="LineLength" />
|
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]env[/\\]EnvironmentTests.java" checks="LineLength" />
|
||||||
|
|
|
@ -170,7 +170,8 @@ public class TransportClusterHealthAction
|
||||||
}
|
}
|
||||||
|
|
||||||
final ClusterState state = clusterService.state();
|
final ClusterState state = clusterService.state();
|
||||||
final ClusterStateObserver observer = new ClusterStateObserver(state, clusterService, null, logger, threadPool.getThreadContext());
|
final ClusterStateObserver observer = new ClusterStateObserver(state, clusterService,
|
||||||
|
null, logger, threadPool.getThreadContext());
|
||||||
if (request.timeout().millis() == 0) {
|
if (request.timeout().millis() == 0) {
|
||||||
listener.onResponse(getResponse(request, state, waitFor, request.timeout().millis() == 0));
|
listener.onResponse(getResponse(request, state, waitFor, request.timeout().millis() == 0));
|
||||||
return;
|
return;
|
||||||
|
@ -209,8 +210,8 @@ public class TransportClusterHealthAction
|
||||||
return readyCounter == waitFor;
|
return readyCounter == waitFor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClusterHealthResponse getResponse(final ClusterHealthRequest request, ClusterState clusterState, final int waitFor,
|
private ClusterHealthResponse getResponse(final ClusterHealthRequest request, ClusterState clusterState,
|
||||||
boolean timedOut) {
|
final int waitFor, boolean timedOut) {
|
||||||
ClusterHealthResponse response = clusterHealth(request, clusterState, clusterService.getMasterService().numberOfPendingTasks(),
|
ClusterHealthResponse response = clusterHealth(request, clusterState, clusterService.getMasterService().numberOfPendingTasks(),
|
||||||
gatewayAllocator.getNumberOfInFlightFetch(), clusterService.getMasterService().getMaxTaskWaitTime());
|
gatewayAllocator.getNumberOfInFlightFetch(), clusterService.getMasterService().getMaxTaskWaitTime());
|
||||||
int readyCounter = prepareResponse(request, response, clusterState, indexNameExpressionResolver);
|
int readyCounter = prepareResponse(request, response, clusterState, indexNameExpressionResolver);
|
||||||
|
@ -325,7 +326,7 @@ public class TransportClusterHealthAction
|
||||||
// one of the specified indices is not there - treat it as RED.
|
// one of the specified indices is not there - treat it as RED.
|
||||||
ClusterHealthResponse response = new ClusterHealthResponse(clusterState.getClusterName().value(), Strings.EMPTY_ARRAY,
|
ClusterHealthResponse response = new ClusterHealthResponse(clusterState.getClusterName().value(), Strings.EMPTY_ARRAY,
|
||||||
clusterState, numberOfPendingTasks, numberOfInFlightFetch, UnassignedInfo.getNumberOfDelayedUnassigned(clusterState),
|
clusterState, numberOfPendingTasks, numberOfInFlightFetch, UnassignedInfo.getNumberOfDelayedUnassigned(clusterState),
|
||||||
pendingTaskTimeInQueue);
|
pendingTaskTimeInQueue);
|
||||||
response.setStatus(ClusterHealthStatus.RED);
|
response.setStatus(ClusterHealthStatus.RED);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,8 @@ public class ClusterStatsNodeResponse extends BaseNodeResponse {
|
||||||
ClusterStatsNodeResponse() {
|
ClusterStatsNodeResponse() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClusterStatsNodeResponse(DiscoveryNode node, @Nullable ClusterHealthStatus clusterStatus, NodeInfo nodeInfo,
|
public ClusterStatsNodeResponse(DiscoveryNode node, @Nullable ClusterHealthStatus clusterStatus,
|
||||||
NodeStats nodeStats, ShardStats[] shardsStats) {
|
NodeInfo nodeInfo, NodeStats nodeStats, ShardStats[] shardsStats) {
|
||||||
super(node);
|
super(node);
|
||||||
this.nodeInfo = nodeInfo;
|
this.nodeInfo = nodeInfo;
|
||||||
this.nodeStats = nodeStats;
|
this.nodeStats = nodeStats;
|
||||||
|
|
|
@ -171,7 +171,8 @@ public final class SearchPhaseController {
|
||||||
final TopDocsAndMaxScore td = queryResult.consumeTopDocs();
|
final TopDocsAndMaxScore td = queryResult.consumeTopDocs();
|
||||||
assert td != null;
|
assert td != null;
|
||||||
topDocsStats.add(td);
|
topDocsStats.add(td);
|
||||||
if (td.topDocs.scoreDocs.length > 0) { // make sure we set the shard index before we add it - the consumer didn't do that yet
|
// make sure we set the shard index before we add it - the consumer didn't do that yet
|
||||||
|
if (td.topDocs.scoreDocs.length > 0) {
|
||||||
setShardIndex(td.topDocs, queryResult.getShardIndex());
|
setShardIndex(td.topDocs, queryResult.getShardIndex());
|
||||||
topDocs.add(td.topDocs);
|
topDocs.add(td.topDocs);
|
||||||
}
|
}
|
||||||
|
@ -308,7 +309,8 @@ public final class SearchPhaseController {
|
||||||
* completion suggestion ordered by suggestion name
|
* completion suggestion ordered by suggestion name
|
||||||
*/
|
*/
|
||||||
public InternalSearchResponse merge(boolean ignoreFrom, ReducedQueryPhase reducedQueryPhase,
|
public InternalSearchResponse merge(boolean ignoreFrom, ReducedQueryPhase reducedQueryPhase,
|
||||||
Collection<? extends SearchPhaseResult> fetchResults, IntFunction<SearchPhaseResult> resultsLookup) {
|
Collection<? extends SearchPhaseResult> fetchResults,
|
||||||
|
IntFunction<SearchPhaseResult> resultsLookup) {
|
||||||
if (reducedQueryPhase.isEmptyResult) {
|
if (reducedQueryPhase.isEmptyResult) {
|
||||||
return InternalSearchResponse.empty();
|
return InternalSearchResponse.empty();
|
||||||
}
|
}
|
||||||
|
@ -416,7 +418,8 @@ public final class SearchPhaseController {
|
||||||
* Reduces the given query results and consumes all aggregations and profile results.
|
* Reduces the given query results and consumes all aggregations and profile results.
|
||||||
* @param queryResults a list of non-null query shard results
|
* @param queryResults a list of non-null query shard results
|
||||||
*/
|
*/
|
||||||
public ReducedQueryPhase reducedQueryPhase(Collection<? extends SearchPhaseResult> queryResults, boolean isScrollRequest, boolean trackTotalHits) {
|
public ReducedQueryPhase reducedQueryPhase(Collection<? extends SearchPhaseResult> queryResults,
|
||||||
|
boolean isScrollRequest, boolean trackTotalHits) {
|
||||||
return reducedQueryPhase(queryResults, null, new ArrayList<>(), new TopDocsStats(trackTotalHits), 0, isScrollRequest);
|
return reducedQueryPhase(queryResults, null, new ArrayList<>(), new TopDocsStats(trackTotalHits), 0, isScrollRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,7 +444,8 @@ public final class SearchPhaseController {
|
||||||
Boolean terminatedEarly = null;
|
Boolean terminatedEarly = null;
|
||||||
if (queryResults.isEmpty()) { // early terminate we have nothing to reduce
|
if (queryResults.isEmpty()) { // early terminate we have nothing to reduce
|
||||||
return new ReducedQueryPhase(topDocsStats.totalHits, topDocsStats.fetchHits, topDocsStats.maxScore,
|
return new ReducedQueryPhase(topDocsStats.totalHits, topDocsStats.fetchHits, topDocsStats.maxScore,
|
||||||
timedOut, terminatedEarly, null, null, null, EMPTY_DOCS, null, null, numReducePhases, false, 0, 0, true);
|
timedOut, terminatedEarly, null, null, null, EMPTY_DOCS, null,
|
||||||
|
null, numReducePhases, false, 0, 0, true);
|
||||||
}
|
}
|
||||||
final QuerySearchResult firstResult = queryResults.stream().findFirst().get().queryResult();
|
final QuerySearchResult firstResult = queryResults.stream().findFirst().get().queryResult();
|
||||||
final boolean hasSuggest = firstResult.suggest() != null;
|
final boolean hasSuggest = firstResult.suggest() != null;
|
||||||
|
@ -671,7 +675,8 @@ public final class SearchPhaseController {
|
||||||
}
|
}
|
||||||
if (hasTopDocs) {
|
if (hasTopDocs) {
|
||||||
TopDocs reducedTopDocs = controller.mergeTopDocs(Arrays.asList(topDocsBuffer),
|
TopDocs reducedTopDocs = controller.mergeTopDocs(Arrays.asList(topDocsBuffer),
|
||||||
querySearchResult.from() + querySearchResult.size() // we have to merge here in the same way we collect on a shard
|
// we have to merge here in the same way we collect on a shard
|
||||||
|
querySearchResult.from() + querySearchResult.size()
|
||||||
, 0);
|
, 0);
|
||||||
Arrays.fill(topDocsBuffer, null);
|
Arrays.fill(topDocsBuffer, null);
|
||||||
topDocsBuffer[0] = reducedTopDocs;
|
topDocsBuffer[0] = reducedTopDocs;
|
||||||
|
|
|
@ -38,7 +38,8 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class MultiTermVectorsRequest extends ActionRequest implements Iterable<TermVectorsRequest>, CompositeIndicesRequest, RealtimeRequest {
|
public class MultiTermVectorsRequest extends ActionRequest
|
||||||
|
implements Iterable<TermVectorsRequest>, CompositeIndicesRequest, RealtimeRequest {
|
||||||
|
|
||||||
String preference;
|
String preference;
|
||||||
List<TermVectorsRequest> requests = new ArrayList<>();
|
List<TermVectorsRequest> requests = new ArrayList<>();
|
||||||
|
|
|
@ -616,18 +616,21 @@ public class TermVectorsRequest extends SingleShardRequest<TermVectorsRequest> i
|
||||||
termVectorsRequest.perFieldAnalyzer(readPerFieldAnalyzer(parser.map()));
|
termVectorsRequest.perFieldAnalyzer(readPerFieldAnalyzer(parser.map()));
|
||||||
} else if (FILTER.match(currentFieldName, parser.getDeprecationHandler())) {
|
} else if (FILTER.match(currentFieldName, parser.getDeprecationHandler())) {
|
||||||
termVectorsRequest.filterSettings(readFilterSettings(parser));
|
termVectorsRequest.filterSettings(readFilterSettings(parser));
|
||||||
} else if (INDEX.match(currentFieldName, parser.getDeprecationHandler())) { // the following is important for multi request parsing.
|
} else if (INDEX.match(currentFieldName, parser.getDeprecationHandler())) {
|
||||||
|
// the following is important for multi request parsing.
|
||||||
termVectorsRequest.index = parser.text();
|
termVectorsRequest.index = parser.text();
|
||||||
} else if (TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
|
} else if (TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
|
||||||
termVectorsRequest.type = parser.text();
|
termVectorsRequest.type = parser.text();
|
||||||
} else if (ID.match(currentFieldName, parser.getDeprecationHandler())) {
|
} else if (ID.match(currentFieldName, parser.getDeprecationHandler())) {
|
||||||
if (termVectorsRequest.doc != null) {
|
if (termVectorsRequest.doc != null) {
|
||||||
throw new ElasticsearchParseException("failed to parse term vectors request. either [id] or [doc] can be specified, but not both!");
|
throw new ElasticsearchParseException("failed to parse term vectors request. " +
|
||||||
|
"either [id] or [doc] can be specified, but not both!");
|
||||||
}
|
}
|
||||||
termVectorsRequest.id = parser.text();
|
termVectorsRequest.id = parser.text();
|
||||||
} else if (DOC.match(currentFieldName, parser.getDeprecationHandler())) {
|
} else if (DOC.match(currentFieldName, parser.getDeprecationHandler())) {
|
||||||
if (termVectorsRequest.id != null) {
|
if (termVectorsRequest.id != null) {
|
||||||
throw new ElasticsearchParseException("failed to parse term vectors request. either [id] or [doc] can be specified, but not both!");
|
throw new ElasticsearchParseException("failed to parse term vectors request. " +
|
||||||
|
"either [id] or [doc] can be specified, but not both!");
|
||||||
}
|
}
|
||||||
termVectorsRequest.doc(jsonBuilder().copyCurrentStructure(parser));
|
termVectorsRequest.doc(jsonBuilder().copyCurrentStructure(parser));
|
||||||
} else if (ROUTING.match(currentFieldName, parser.getDeprecationHandler())) {
|
} else if (ROUTING.match(currentFieldName, parser.getDeprecationHandler())) {
|
||||||
|
@ -653,7 +656,8 @@ public class TermVectorsRequest extends SingleShardRequest<TermVectorsRequest> i
|
||||||
if (e.getValue() instanceof String) {
|
if (e.getValue() instanceof String) {
|
||||||
mapStrStr.put(e.getKey(), (String) e.getValue());
|
mapStrStr.put(e.getKey(), (String) e.getValue());
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("expecting the analyzer at [{}] to be a String, but found [{}] instead", e.getKey(), e.getValue().getClass());
|
throw new ElasticsearchParseException("expecting the analyzer at [{}] to be a String, but found [{}] instead",
|
||||||
|
e.getKey(), e.getValue().getClass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mapStrStr;
|
return mapStrStr;
|
||||||
|
@ -682,7 +686,8 @@ public class TermVectorsRequest extends SingleShardRequest<TermVectorsRequest> i
|
||||||
} else if (currentFieldName.equals("max_word_length")) {
|
} else if (currentFieldName.equals("max_word_length")) {
|
||||||
settings.maxWordLength = parser.intValue();
|
settings.maxWordLength = parser.intValue();
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("failed to parse term vectors request. the field [{}] is not valid for filter parameter for term vector request", currentFieldName);
|
throw new ElasticsearchParseException("failed to parse term vectors request. " +
|
||||||
|
"the field [{}] is not valid for filter parameter for term vector request", currentFieldName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,7 +197,8 @@ public class TermVectorsResponse extends ActionResponse implements ToXContentObj
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildField(XContentBuilder builder, final CharsRefBuilder spare, Fields theFields, Iterator<String> fieldIter) throws IOException {
|
private void buildField(XContentBuilder builder, final CharsRefBuilder spare,
|
||||||
|
Fields theFields, Iterator<String> fieldIter) throws IOException {
|
||||||
String fieldName = fieldIter.next();
|
String fieldName = fieldIter.next();
|
||||||
builder.startObject(fieldName);
|
builder.startObject(fieldName);
|
||||||
Terms curTerms = theFields.terms(fieldName);
|
Terms curTerms = theFields.terms(fieldName);
|
||||||
|
@ -213,7 +214,8 @@ public class TermVectorsResponse extends ActionResponse implements ToXContentObj
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildTerm(XContentBuilder builder, final CharsRefBuilder spare, Terms curTerms, TermsEnum termIter, BoostAttribute boostAtt) throws IOException {
|
private void buildTerm(XContentBuilder builder, final CharsRefBuilder spare, Terms curTerms,
|
||||||
|
TermsEnum termIter, BoostAttribute boostAtt) throws IOException {
|
||||||
// start term, optimized writing
|
// start term, optimized writing
|
||||||
BytesRef term = termIter.next();
|
BytesRef term = termIter.next();
|
||||||
spare.copyUTF8Bytes(term);
|
spare.copyUTF8Bytes(term);
|
||||||
|
@ -235,7 +237,8 @@ public class TermVectorsResponse extends ActionResponse implements ToXContentObj
|
||||||
// boolean that says if these values actually were requested.
|
// boolean that says if these values actually were requested.
|
||||||
// However, we can assume that they were not if the statistic values are
|
// However, we can assume that they were not if the statistic values are
|
||||||
// <= 0.
|
// <= 0.
|
||||||
assert (((termIter.docFreq() > 0) && (termIter.totalTermFreq() > 0)) || ((termIter.docFreq() == -1) && (termIter.totalTermFreq() == -1)));
|
assert (((termIter.docFreq() > 0) && (termIter.totalTermFreq() > 0)) ||
|
||||||
|
((termIter.docFreq() == -1) && (termIter.totalTermFreq() == -1)));
|
||||||
int docFreq = termIter.docFreq();
|
int docFreq = termIter.docFreq();
|
||||||
if (docFreq > 0) {
|
if (docFreq > 0) {
|
||||||
builder.field(FieldStrings.DOC_FREQ, docFreq);
|
builder.field(FieldStrings.DOC_FREQ, docFreq);
|
||||||
|
@ -349,12 +352,13 @@ public class TermVectorsResponse extends ActionResponse implements ToXContentObj
|
||||||
this.exists = exists;
|
this.exists = exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFields(Fields termVectorsByField, Set<String> selectedFields, EnumSet<Flag> flags, Fields topLevelFields) throws IOException {
|
public void setFields(Fields termVectorsByField, Set<String> selectedFields,
|
||||||
|
EnumSet<Flag> flags, Fields topLevelFields) throws IOException {
|
||||||
setFields(termVectorsByField, selectedFields, flags, topLevelFields, null, null);
|
setFields(termVectorsByField, selectedFields, flags, topLevelFields, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFields(Fields termVectorsByField, Set<String> selectedFields, EnumSet<Flag> flags, Fields topLevelFields, @Nullable AggregatedDfs dfs,
|
public void setFields(Fields termVectorsByField, Set<String> selectedFields, EnumSet<Flag> flags,
|
||||||
TermVectorsFilter termVectorsFilter) throws IOException {
|
Fields topLevelFields, @Nullable AggregatedDfs dfs, TermVectorsFilter termVectorsFilter) throws IOException {
|
||||||
TermVectorsWriter tvw = new TermVectorsWriter(this);
|
TermVectorsWriter tvw = new TermVectorsWriter(this);
|
||||||
|
|
||||||
if (termVectorsByField != null) {
|
if (termVectorsByField != null) {
|
||||||
|
|
|
@ -141,10 +141,12 @@ final class TermVectorsWriter {
|
||||||
numFieldsWritten++;
|
numFieldsWritten++;
|
||||||
}
|
}
|
||||||
response.setTermVectorsField(output);
|
response.setTermVectorsField(output);
|
||||||
response.setHeader(writeHeader(numFieldsWritten, flags.contains(Flag.TermStatistics), flags.contains(Flag.FieldStatistics), hasScores));
|
response.setHeader(writeHeader(numFieldsWritten, flags.contains(Flag.TermStatistics),
|
||||||
|
flags.contains(Flag.FieldStatistics), hasScores));
|
||||||
}
|
}
|
||||||
|
|
||||||
private BytesReference writeHeader(int numFieldsWritten, boolean getTermStatistics, boolean getFieldStatistics, boolean scores) throws IOException {
|
private BytesReference writeHeader(int numFieldsWritten, boolean getTermStatistics,
|
||||||
|
boolean getFieldStatistics, boolean scores) throws IOException {
|
||||||
// now, write the information about offset of the terms in the
|
// now, write the information about offset of the terms in the
|
||||||
// termVectors field
|
// termVectors field
|
||||||
BytesStreamOutput header = new BytesStreamOutput();
|
BytesStreamOutput header = new BytesStreamOutput();
|
||||||
|
|
|
@ -64,16 +64,20 @@ public class TransportMultiTermVectorsAction extends HandledTransportAction<Mult
|
||||||
Map<ShardId, MultiTermVectorsShardRequest> shardRequests = new HashMap<>();
|
Map<ShardId, MultiTermVectorsShardRequest> shardRequests = new HashMap<>();
|
||||||
for (int i = 0; i < request.requests.size(); i++) {
|
for (int i = 0; i < request.requests.size(); i++) {
|
||||||
TermVectorsRequest termVectorsRequest = request.requests.get(i);
|
TermVectorsRequest termVectorsRequest = request.requests.get(i);
|
||||||
termVectorsRequest.routing(clusterState.metaData().resolveIndexRouting(termVectorsRequest.routing(), termVectorsRequest.index()));
|
termVectorsRequest.routing(clusterState.metaData().resolveIndexRouting(termVectorsRequest.routing(),
|
||||||
|
termVectorsRequest.index()));
|
||||||
if (!clusterState.metaData().hasConcreteIndex(termVectorsRequest.index())) {
|
if (!clusterState.metaData().hasConcreteIndex(termVectorsRequest.index())) {
|
||||||
responses.set(i, new MultiTermVectorsItemResponse(null, new MultiTermVectorsResponse.Failure(termVectorsRequest.index(),
|
responses.set(i, new MultiTermVectorsItemResponse(null, new MultiTermVectorsResponse.Failure(termVectorsRequest.index(),
|
||||||
termVectorsRequest.type(), termVectorsRequest.id(), new IndexNotFoundException(termVectorsRequest.index()))));
|
termVectorsRequest.type(), termVectorsRequest.id(), new IndexNotFoundException(termVectorsRequest.index()))));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String concreteSingleIndex = indexNameExpressionResolver.concreteSingleIndex(clusterState, termVectorsRequest).getName();
|
String concreteSingleIndex = indexNameExpressionResolver.concreteSingleIndex(clusterState, termVectorsRequest).getName();
|
||||||
if (termVectorsRequest.routing() == null && clusterState.getMetaData().routingRequired(concreteSingleIndex, termVectorsRequest.type())) {
|
if (termVectorsRequest.routing() == null &&
|
||||||
responses.set(i, new MultiTermVectorsItemResponse(null, new MultiTermVectorsResponse.Failure(concreteSingleIndex, termVectorsRequest.type(), termVectorsRequest.id(),
|
clusterState.getMetaData().routingRequired(concreteSingleIndex, termVectorsRequest.type())) {
|
||||||
new IllegalArgumentException("routing is required for [" + concreteSingleIndex + "]/[" + termVectorsRequest.type() + "]/[" + termVectorsRequest.id() + "]"))));
|
responses.set(i, new MultiTermVectorsItemResponse(null,
|
||||||
|
new MultiTermVectorsResponse.Failure(concreteSingleIndex, termVectorsRequest.type(), termVectorsRequest.id(),
|
||||||
|
new IllegalArgumentException("routing is required for [" + concreteSingleIndex + "]/[" +
|
||||||
|
termVectorsRequest.type() + "]/[" + termVectorsRequest.id() + "]"))));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ShardId shardId = clusterService.operationRouting().shardId(clusterState, concreteSingleIndex,
|
ShardId shardId = clusterService.operationRouting().shardId(clusterState, concreteSingleIndex,
|
||||||
|
|
|
@ -36,7 +36,8 @@ import org.elasticsearch.indices.IndicesService;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
|
||||||
public class TransportShardMultiTermsVectorAction extends TransportSingleShardAction<MultiTermVectorsShardRequest, MultiTermVectorsShardResponse> {
|
public class TransportShardMultiTermsVectorAction extends
|
||||||
|
TransportSingleShardAction<MultiTermVectorsShardRequest, MultiTermVectorsShardResponse> {
|
||||||
|
|
||||||
private final IndicesService indicesService;
|
private final IndicesService indicesService;
|
||||||
|
|
||||||
|
@ -86,7 +87,8 @@ public class TransportShardMultiTermsVectorAction extends TransportSingleShardAc
|
||||||
if (TransportActions.isShardNotAvailableException(e)) {
|
if (TransportActions.isShardNotAvailableException(e)) {
|
||||||
throw e;
|
throw e;
|
||||||
} else {
|
} else {
|
||||||
logger.debug(() -> new ParameterizedMessage("{} failed to execute multi term vectors for [{}]/[{}]", shardId, termVectorsRequest.type(), termVectorsRequest.id()), e);
|
logger.debug(() -> new ParameterizedMessage("{} failed to execute multi term vectors for [{}]/[{}]",
|
||||||
|
shardId, termVectorsRequest.type(), termVectorsRequest.id()), e);
|
||||||
response.add(request.locations.get(i),
|
response.add(request.locations.get(i),
|
||||||
new MultiTermVectorsResponse.Failure(request.index(), termVectorsRequest.type(), termVectorsRequest.id(), e));
|
new MultiTermVectorsResponse.Failure(request.index(), termVectorsRequest.type(), termVectorsRequest.id(), e));
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,8 @@ public class TransportTermVectorsAction extends TransportSingleShardAction<TermV
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void asyncShardOperation(TermVectorsRequest request, ShardId shardId, ActionListener<TermVectorsResponse> listener) throws IOException {
|
protected void asyncShardOperation(TermVectorsRequest request, ShardId shardId,
|
||||||
|
ActionListener<TermVectorsResponse> listener) throws IOException {
|
||||||
IndexService indexService = indicesService.indexServiceSafe(shardId.getIndex());
|
IndexService indexService = indicesService.indexServiceSafe(shardId.getIndex());
|
||||||
IndexShard indexShard = indexService.getShard(shardId.id());
|
IndexShard indexShard = indexService.getShard(shardId.id());
|
||||||
if (request.realtime()) { // it's a realtime request which is not subject to refresh cycles
|
if (request.realtime()) { // it's a realtime request which is not subject to refresh cycles
|
||||||
|
|
|
@ -75,7 +75,8 @@ public class TransportUpdateAction extends TransportInstanceSingleOperationActio
|
||||||
UpdateHelper updateHelper, ActionFilters actionFilters,
|
UpdateHelper updateHelper, ActionFilters actionFilters,
|
||||||
IndexNameExpressionResolver indexNameExpressionResolver, IndicesService indicesService,
|
IndexNameExpressionResolver indexNameExpressionResolver, IndicesService indicesService,
|
||||||
AutoCreateIndex autoCreateIndex, NodeClient client) {
|
AutoCreateIndex autoCreateIndex, NodeClient client) {
|
||||||
super(UpdateAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver, UpdateRequest::new);
|
super(UpdateAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
||||||
|
indexNameExpressionResolver, UpdateRequest::new);
|
||||||
this.updateHelper = updateHelper;
|
this.updateHelper = updateHelper;
|
||||||
this.indicesService = indicesService;
|
this.indicesService = indicesService;
|
||||||
this.autoCreateIndex = autoCreateIndex;
|
this.autoCreateIndex = autoCreateIndex;
|
||||||
|
@ -114,7 +115,8 @@ public class TransportUpdateAction extends TransportInstanceSingleOperationActio
|
||||||
protected void doExecute(Task task, final UpdateRequest request, final ActionListener<UpdateResponse> listener) {
|
protected void doExecute(Task task, final UpdateRequest request, final ActionListener<UpdateResponse> listener) {
|
||||||
// if we don't have a master, we don't have metadata, that's fine, let it find a master using create index API
|
// if we don't have a master, we don't have metadata, that's fine, let it find a master using create index API
|
||||||
if (autoCreateIndex.shouldAutoCreate(request.index(), clusterService.state())) {
|
if (autoCreateIndex.shouldAutoCreate(request.index(), clusterService.state())) {
|
||||||
client.admin().indices().create(new CreateIndexRequest().index(request.index()).cause("auto(update api)").masterNodeTimeout(request.timeout()), new ActionListener<CreateIndexResponse>() {
|
client.admin().indices().create(new CreateIndexRequest().index(request.index()).cause("auto(update api)")
|
||||||
|
.masterNodeTimeout(request.timeout()), new ActionListener<CreateIndexResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(CreateIndexResponse result) {
|
public void onResponse(CreateIndexResponse result) {
|
||||||
innerExecute(task, request, listener);
|
innerExecute(task, request, listener);
|
||||||
|
@ -177,11 +179,14 @@ public class TransportUpdateAction extends TransportInstanceSingleOperationActio
|
||||||
final BytesReference upsertSourceBytes = upsertRequest.source();
|
final BytesReference upsertSourceBytes = upsertRequest.source();
|
||||||
client.bulk(toSingleItemBulkRequest(upsertRequest), wrapBulkResponse(
|
client.bulk(toSingleItemBulkRequest(upsertRequest), wrapBulkResponse(
|
||||||
ActionListener.<IndexResponse>wrap(response -> {
|
ActionListener.<IndexResponse>wrap(response -> {
|
||||||
UpdateResponse update = new UpdateResponse(response.getShardInfo(), response.getShardId(), response.getType(), response.getId(), response.getSeqNo(), response.getPrimaryTerm(), response.getVersion(), response.getResult());
|
UpdateResponse update = new UpdateResponse(response.getShardInfo(), response.getShardId(),
|
||||||
|
response.getType(), response.getId(), response.getSeqNo(), response.getPrimaryTerm(),
|
||||||
|
response.getVersion(), response.getResult());
|
||||||
if (request.fetchSource() != null && request.fetchSource().fetchSource()) {
|
if (request.fetchSource() != null && request.fetchSource().fetchSource()) {
|
||||||
Tuple<XContentType, Map<String, Object>> sourceAndContent =
|
Tuple<XContentType, Map<String, Object>> sourceAndContent =
|
||||||
XContentHelper.convertToMap(upsertSourceBytes, true, upsertRequest.getContentType());
|
XContentHelper.convertToMap(upsertSourceBytes, true, upsertRequest.getContentType());
|
||||||
update.setGetResult(UpdateHelper.extractGetResult(request, request.concreteIndex(), response.getVersion(), sourceAndContent.v2(), sourceAndContent.v1(), upsertSourceBytes));
|
update.setGetResult(UpdateHelper.extractGetResult(request, request.concreteIndex(), response.getVersion(),
|
||||||
|
sourceAndContent.v2(), sourceAndContent.v1(), upsertSourceBytes));
|
||||||
} else {
|
} else {
|
||||||
update.setGetResult(null);
|
update.setGetResult(null);
|
||||||
}
|
}
|
||||||
|
@ -197,8 +202,11 @@ public class TransportUpdateAction extends TransportInstanceSingleOperationActio
|
||||||
final BytesReference indexSourceBytes = indexRequest.source();
|
final BytesReference indexSourceBytes = indexRequest.source();
|
||||||
client.bulk(toSingleItemBulkRequest(indexRequest), wrapBulkResponse(
|
client.bulk(toSingleItemBulkRequest(indexRequest), wrapBulkResponse(
|
||||||
ActionListener.<IndexResponse>wrap(response -> {
|
ActionListener.<IndexResponse>wrap(response -> {
|
||||||
UpdateResponse update = new UpdateResponse(response.getShardInfo(), response.getShardId(), response.getType(), response.getId(), response.getSeqNo(), response.getPrimaryTerm(), response.getVersion(), response.getResult());
|
UpdateResponse update = new UpdateResponse(response.getShardInfo(), response.getShardId(),
|
||||||
update.setGetResult(UpdateHelper.extractGetResult(request, request.concreteIndex(), response.getVersion(), result.updatedSourceAsMap(), result.updateSourceContentType(), indexSourceBytes));
|
response.getType(), response.getId(), response.getSeqNo(), response.getPrimaryTerm(),
|
||||||
|
response.getVersion(), response.getResult());
|
||||||
|
update.setGetResult(UpdateHelper.extractGetResult(request, request.concreteIndex(), response.getVersion(),
|
||||||
|
result.updatedSourceAsMap(), result.updateSourceContentType(), indexSourceBytes));
|
||||||
update.setForcedRefresh(response.forcedRefresh());
|
update.setForcedRefresh(response.forcedRefresh());
|
||||||
listener.onResponse(update);
|
listener.onResponse(update);
|
||||||
}, exception -> handleUpdateFailureWithRetry(listener, request, exception, retryCount)))
|
}, exception -> handleUpdateFailureWithRetry(listener, request, exception, retryCount)))
|
||||||
|
@ -208,8 +216,11 @@ public class TransportUpdateAction extends TransportInstanceSingleOperationActio
|
||||||
DeleteRequest deleteRequest = result.action();
|
DeleteRequest deleteRequest = result.action();
|
||||||
client.bulk(toSingleItemBulkRequest(deleteRequest), wrapBulkResponse(
|
client.bulk(toSingleItemBulkRequest(deleteRequest), wrapBulkResponse(
|
||||||
ActionListener.<DeleteResponse>wrap(response -> {
|
ActionListener.<DeleteResponse>wrap(response -> {
|
||||||
UpdateResponse update = new UpdateResponse(response.getShardInfo(), response.getShardId(), response.getType(), response.getId(), response.getSeqNo(), response.getPrimaryTerm(), response.getVersion(), response.getResult());
|
UpdateResponse update = new UpdateResponse(response.getShardInfo(), response.getShardId(),
|
||||||
update.setGetResult(UpdateHelper.extractGetResult(request, request.concreteIndex(), response.getVersion(), result.updatedSourceAsMap(), result.updateSourceContentType(), null));
|
response.getType(), response.getId(), response.getSeqNo(), response.getPrimaryTerm(),
|
||||||
|
response.getVersion(), response.getResult());
|
||||||
|
update.setGetResult(UpdateHelper.extractGetResult(request, request.concreteIndex(), response.getVersion(),
|
||||||
|
result.updatedSourceAsMap(), result.updateSourceContentType(), null));
|
||||||
update.setForcedRefresh(response.forcedRefresh());
|
update.setForcedRefresh(response.forcedRefresh());
|
||||||
listener.onResponse(update);
|
listener.onResponse(update);
|
||||||
}, exception -> handleUpdateFailureWithRetry(listener, request, exception, retryCount)))
|
}, exception -> handleUpdateFailureWithRetry(listener, request, exception, retryCount)))
|
||||||
|
|
|
@ -149,11 +149,13 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (version != Versions.MATCH_ANY && retryOnConflict > 0) {
|
if (version != Versions.MATCH_ANY && retryOnConflict > 0) {
|
||||||
validationException = addValidationError("can't provide both retry_on_conflict and a specific version", validationException);
|
validationException = addValidationError("can't provide both retry_on_conflict and a specific version",
|
||||||
|
validationException);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!versionType.validateVersionForWrites(version)) {
|
if (!versionType.validateVersionForWrites(version)) {
|
||||||
validationException = addValidationError("illegal version value [" + version + "] for version type [" + versionType.name() + "]", validationException);
|
validationException = addValidationError("illegal version value [" + version + "] for version type [" +
|
||||||
|
versionType.name() + "]", validationException);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -618,8 +620,8 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the index request to be used if the document does not exists. Otherwise, a {@link org.elasticsearch.index.engine.DocumentMissingException}
|
* Sets the index request to be used if the document does not exists. Otherwise, a
|
||||||
* is thrown.
|
* {@link org.elasticsearch.index.engine.DocumentMissingException} is thrown.
|
||||||
*/
|
*/
|
||||||
public UpdateRequest upsert(IndexRequest upsertRequest) {
|
public UpdateRequest upsert(IndexRequest upsertRequest) {
|
||||||
this.upsertRequest = upsertRequest;
|
this.upsertRequest = upsertRequest;
|
||||||
|
|
|
@ -243,8 +243,8 @@ public class UpdateRequestBuilder extends InstanceShardOperationRequestBuilder<U
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the index request to be used if the document does not exists. Otherwise, a {@link org.elasticsearch.index.engine.DocumentMissingException}
|
* Sets the index request to be used if the document does not exists. Otherwise, a
|
||||||
* is thrown.
|
* {@link org.elasticsearch.index.engine.DocumentMissingException} is thrown.
|
||||||
*/
|
*/
|
||||||
public UpdateRequestBuilder setUpsert(IndexRequest indexRequest) {
|
public UpdateRequestBuilder setUpsert(IndexRequest indexRequest) {
|
||||||
request.upsert(indexRequest);
|
request.upsert(indexRequest);
|
||||||
|
|
|
@ -87,7 +87,8 @@ public class RejectionActionIT extends ESIntegTestCase {
|
||||||
if (response instanceof SearchResponse) {
|
if (response instanceof SearchResponse) {
|
||||||
SearchResponse searchResponse = (SearchResponse) response;
|
SearchResponse searchResponse = (SearchResponse) response;
|
||||||
for (ShardSearchFailure failure : searchResponse.getShardFailures()) {
|
for (ShardSearchFailure failure : searchResponse.getShardFailures()) {
|
||||||
assertTrue("got unexpected reason..." + failure.reason(), failure.reason().toLowerCase(Locale.ENGLISH).contains("rejected"));
|
assertTrue("got unexpected reason..." + failure.reason(),
|
||||||
|
failure.reason().toLowerCase(Locale.ENGLISH).contains("rejected"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Exception t = (Exception) response;
|
Exception t = (Exception) response;
|
||||||
|
@ -95,7 +96,8 @@ public class RejectionActionIT extends ESIntegTestCase {
|
||||||
if (unwrap instanceof SearchPhaseExecutionException) {
|
if (unwrap instanceof SearchPhaseExecutionException) {
|
||||||
SearchPhaseExecutionException e = (SearchPhaseExecutionException) unwrap;
|
SearchPhaseExecutionException e = (SearchPhaseExecutionException) unwrap;
|
||||||
for (ShardSearchFailure failure : e.shardFailures()) {
|
for (ShardSearchFailure failure : e.shardFailures()) {
|
||||||
assertTrue("got unexpected reason..." + failure.reason(), failure.reason().toLowerCase(Locale.ENGLISH).contains("rejected"));
|
assertTrue("got unexpected reason..." + failure.reason(),
|
||||||
|
failure.reason().toLowerCase(Locale.ENGLISH).contains("rejected"));
|
||||||
}
|
}
|
||||||
} else if ((unwrap instanceof EsRejectedExecutionException) == false) {
|
} else if ((unwrap instanceof EsRejectedExecutionException) == false) {
|
||||||
throw new AssertionError("unexpected failure", (Throwable) response);
|
throw new AssertionError("unexpected failure", (Throwable) response);
|
||||||
|
|
|
@ -120,7 +120,8 @@ public class HotThreadsIT extends ESIntegTestCase {
|
||||||
assertHitCount(
|
assertHitCount(
|
||||||
client().prepareSearch()
|
client().prepareSearch()
|
||||||
.setQuery(matchAllQuery())
|
.setQuery(matchAllQuery())
|
||||||
.setPostFilter(boolQuery().must(matchAllQuery()).mustNot(boolQuery().must(termQuery("field1", "value1")).must(termQuery("field1", "value2"))))
|
.setPostFilter(boolQuery().must(matchAllQuery()).mustNot(boolQuery()
|
||||||
|
.must(termQuery("field1", "value1")).must(termQuery("field1", "value2"))))
|
||||||
.get(),
|
.get(),
|
||||||
3L);
|
3L);
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,8 +70,8 @@ public class ClusterHealthResponsesTests extends AbstractStreamableXContentTestC
|
||||||
int inFlight = randomIntBetween(0, 200);
|
int inFlight = randomIntBetween(0, 200);
|
||||||
int delayedUnassigned = randomIntBetween(0, 200);
|
int delayedUnassigned = randomIntBetween(0, 200);
|
||||||
TimeValue pendingTaskInQueueTime = TimeValue.timeValueMillis(randomIntBetween(1000, 100000));
|
TimeValue pendingTaskInQueueTime = TimeValue.timeValueMillis(randomIntBetween(1000, 100000));
|
||||||
ClusterHealthResponse clusterHealth = new ClusterHealthResponse("bla", new String[] {MetaData.ALL}, clusterState, pendingTasks,
|
ClusterHealthResponse clusterHealth = new ClusterHealthResponse("bla", new String[] {MetaData.ALL},
|
||||||
inFlight, delayedUnassigned, pendingTaskInQueueTime);
|
clusterState, pendingTasks, inFlight, delayedUnassigned, pendingTaskInQueueTime);
|
||||||
clusterHealth = maybeSerialize(clusterHealth);
|
clusterHealth = maybeSerialize(clusterHealth);
|
||||||
assertClusterHealth(clusterHealth);
|
assertClusterHealth(clusterHealth);
|
||||||
assertThat(clusterHealth.getNumberOfPendingTasks(), Matchers.equalTo(pendingTasks));
|
assertThat(clusterHealth.getNumberOfPendingTasks(), Matchers.equalTo(pendingTasks));
|
||||||
|
|
|
@ -66,8 +66,8 @@ public class RepositoryBlocksIT extends ESIntegTestCase {
|
||||||
// This test checks that the Get Repository operation is never blocked, even if the cluster is read only.
|
// This test checks that the Get Repository operation is never blocked, even if the cluster is read only.
|
||||||
try {
|
try {
|
||||||
setClusterReadOnly(true);
|
setClusterReadOnly(true);
|
||||||
VerifyRepositoryResponse response = client().admin().cluster().prepareVerifyRepository("test-repo-blocks").execute()
|
VerifyRepositoryResponse response = client().admin().cluster()
|
||||||
.actionGet();
|
.prepareVerifyRepository("test-repo-blocks").execute().actionGet();
|
||||||
assertThat(response.getNodes().size(), equalTo(cluster().numDataAndMasterNodes()));
|
assertThat(response.getNodes().size(), equalTo(cluster().numDataAndMasterNodes()));
|
||||||
} finally {
|
} finally {
|
||||||
setClusterReadOnly(false);
|
setClusterReadOnly(false);
|
||||||
|
|
|
@ -88,10 +88,8 @@ public class SnapshotBlocksIT extends ESIntegTestCase {
|
||||||
logger.info("--> creating a snapshot is allowed when the cluster is read only");
|
logger.info("--> creating a snapshot is allowed when the cluster is read only");
|
||||||
try {
|
try {
|
||||||
setClusterReadOnly(true);
|
setClusterReadOnly(true);
|
||||||
assertThat(
|
assertThat(client().admin().cluster().prepareCreateSnapshot(REPOSITORY_NAME, "snapshot-1")
|
||||||
client().admin().cluster().prepareCreateSnapshot(REPOSITORY_NAME, "snapshot-1").setWaitForCompletion(true).get().status(),
|
.setWaitForCompletion(true).get().status(), equalTo(RestStatus.OK));
|
||||||
equalTo(RestStatus.OK)
|
|
||||||
);
|
|
||||||
} finally {
|
} finally {
|
||||||
setClusterReadOnly(false);
|
setClusterReadOnly(false);
|
||||||
}
|
}
|
||||||
|
@ -107,11 +105,8 @@ public class SnapshotBlocksIT extends ESIntegTestCase {
|
||||||
logger.info("--> creating a snapshot is not blocked when an index is read only");
|
logger.info("--> creating a snapshot is not blocked when an index is read only");
|
||||||
try {
|
try {
|
||||||
enableIndexBlock(INDEX_NAME, SETTING_READ_ONLY);
|
enableIndexBlock(INDEX_NAME, SETTING_READ_ONLY);
|
||||||
assertThat(
|
assertThat(client().admin().cluster().prepareCreateSnapshot(REPOSITORY_NAME, "snapshot-1")
|
||||||
client().admin().cluster().prepareCreateSnapshot(REPOSITORY_NAME, "snapshot-1")
|
.setIndices(COMMON_INDEX_NAME_MASK).setWaitForCompletion(true).get().status(), equalTo(RestStatus.OK));
|
||||||
.setIndices(COMMON_INDEX_NAME_MASK).setWaitForCompletion(true).get().status(),
|
|
||||||
equalTo(RestStatus.OK)
|
|
||||||
);
|
|
||||||
} finally {
|
} finally {
|
||||||
disableIndexBlock(INDEX_NAME, SETTING_READ_ONLY);
|
disableIndexBlock(INDEX_NAME, SETTING_READ_ONLY);
|
||||||
}
|
}
|
||||||
|
@ -119,16 +114,11 @@ public class SnapshotBlocksIT extends ESIntegTestCase {
|
||||||
logger.info("--> creating a snapshot is blocked when an index is blocked for reads");
|
logger.info("--> creating a snapshot is blocked when an index is blocked for reads");
|
||||||
try {
|
try {
|
||||||
enableIndexBlock(INDEX_NAME, SETTING_BLOCKS_READ);
|
enableIndexBlock(INDEX_NAME, SETTING_BLOCKS_READ);
|
||||||
assertBlocked(
|
assertBlocked(client().admin().cluster().prepareCreateSnapshot(REPOSITORY_NAME, "snapshot-2")
|
||||||
client().admin().cluster().prepareCreateSnapshot(REPOSITORY_NAME, "snapshot-2").setIndices(COMMON_INDEX_NAME_MASK),
|
.setIndices(COMMON_INDEX_NAME_MASK), IndexMetaData.INDEX_READ_BLOCK);
|
||||||
IndexMetaData.INDEX_READ_BLOCK
|
|
||||||
);
|
|
||||||
logger.info("--> creating a snapshot is not blocked when an read-blocked index is not part of the snapshot");
|
logger.info("--> creating a snapshot is not blocked when an read-blocked index is not part of the snapshot");
|
||||||
assertThat(
|
assertThat(client().admin().cluster().prepareCreateSnapshot(REPOSITORY_NAME, "snapshot-2")
|
||||||
client().admin().cluster().prepareCreateSnapshot(REPOSITORY_NAME, "snapshot-2").
|
.setIndices(OTHER_INDEX_NAME).setWaitForCompletion(true).get().status(), equalTo(RestStatus.OK));
|
||||||
setIndices(OTHER_INDEX_NAME).setWaitForCompletion(true).get().status(),
|
|
||||||
equalTo(RestStatus.OK)
|
|
||||||
);
|
|
||||||
} finally {
|
} finally {
|
||||||
disableIndexBlock(INDEX_NAME, SETTING_BLOCKS_READ);
|
disableIndexBlock(INDEX_NAME, SETTING_BLOCKS_READ);
|
||||||
}
|
}
|
||||||
|
@ -151,10 +141,8 @@ public class SnapshotBlocksIT extends ESIntegTestCase {
|
||||||
logger.info("--> restoring a snapshot is blocked when the cluster is read only");
|
logger.info("--> restoring a snapshot is blocked when the cluster is read only");
|
||||||
try {
|
try {
|
||||||
setClusterReadOnly(true);
|
setClusterReadOnly(true);
|
||||||
assertBlocked(
|
assertBlocked(client().admin().cluster().prepareRestoreSnapshot(REPOSITORY_NAME, SNAPSHOT_NAME),
|
||||||
client().admin().cluster().prepareRestoreSnapshot(REPOSITORY_NAME, SNAPSHOT_NAME),
|
MetaData.CLUSTER_READ_ONLY_BLOCK);
|
||||||
MetaData.CLUSTER_READ_ONLY_BLOCK
|
|
||||||
);
|
|
||||||
} finally {
|
} finally {
|
||||||
setClusterReadOnly(false);
|
setClusterReadOnly(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,8 @@ public class ClusterStateRequestTests extends ESTestCase {
|
||||||
ClusterStateRequest clusterStateRequest = new ClusterStateRequest().routingTable(randomBoolean()).metaData(randomBoolean())
|
ClusterStateRequest clusterStateRequest = new ClusterStateRequest().routingTable(randomBoolean()).metaData(randomBoolean())
|
||||||
.nodes(randomBoolean()).blocks(randomBoolean()).indices("testindex", "testindex2").indicesOptions(indicesOptions);
|
.nodes(randomBoolean()).blocks(randomBoolean()).indices("testindex", "testindex2").indicesOptions(indicesOptions);
|
||||||
|
|
||||||
Version testVersion = VersionUtils.randomVersionBetween(random(), Version.CURRENT.minimumCompatibilityVersion(),
|
Version testVersion = VersionUtils.randomVersionBetween(random(),
|
||||||
Version.CURRENT);
|
Version.CURRENT.minimumCompatibilityVersion(), Version.CURRENT);
|
||||||
BytesStreamOutput output = new BytesStreamOutput();
|
BytesStreamOutput output = new BytesStreamOutput();
|
||||||
output.setVersion(testVersion);
|
output.setVersion(testVersion);
|
||||||
clusterStateRequest.writeTo(output);
|
clusterStateRequest.writeTo(output);
|
||||||
|
|
|
@ -54,8 +54,8 @@ public class ClusterStatsIT extends ESIntegTestCase {
|
||||||
|
|
||||||
private void waitForNodes(int numNodes) {
|
private void waitForNodes(int numNodes) {
|
||||||
ClusterHealthResponse actionGet = client().admin().cluster()
|
ClusterHealthResponse actionGet = client().admin().cluster()
|
||||||
.health(Requests.clusterHealthRequest().waitForEvents(Priority.LANGUID).waitForNodes(Integer.toString(numNodes)))
|
.health(Requests.clusterHealthRequest().waitForEvents(Priority.LANGUID)
|
||||||
.actionGet();
|
.waitForNodes(Integer.toString(numNodes))).actionGet();
|
||||||
assertThat(actionGet.isTimedOut(), is(false));
|
assertThat(actionGet.isTimedOut(), is(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,13 +64,16 @@ public class SearchRequestBuilderTests extends ESTestCase {
|
||||||
public void testSearchSourceBuilderToString() {
|
public void testSearchSourceBuilderToString() {
|
||||||
SearchRequestBuilder searchRequestBuilder = client.prepareSearch();
|
SearchRequestBuilder searchRequestBuilder = client.prepareSearch();
|
||||||
searchRequestBuilder.setSource(new SearchSourceBuilder().query(QueryBuilders.termQuery("field", "value")));
|
searchRequestBuilder.setSource(new SearchSourceBuilder().query(QueryBuilders.termQuery("field", "value")));
|
||||||
assertThat(searchRequestBuilder.toString(), equalTo(new SearchSourceBuilder().query(QueryBuilders.termQuery("field", "value")).toString()));
|
assertThat(searchRequestBuilder.toString(), equalTo(new SearchSourceBuilder()
|
||||||
|
.query(QueryBuilders.termQuery("field", "value")).toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testThatToStringDoesntWipeRequestSource() {
|
public void testThatToStringDoesntWipeRequestSource() {
|
||||||
SearchRequestBuilder searchRequestBuilder = client.prepareSearch().setSource(new SearchSourceBuilder().query(QueryBuilders.termQuery("field", "value")));
|
SearchRequestBuilder searchRequestBuilder = client.prepareSearch()
|
||||||
|
.setSource(new SearchSourceBuilder().query(QueryBuilders.termQuery("field", "value")));
|
||||||
String preToString = searchRequestBuilder.request().toString();
|
String preToString = searchRequestBuilder.request().toString();
|
||||||
assertThat(searchRequestBuilder.toString(), equalTo(new SearchSourceBuilder().query(QueryBuilders.termQuery("field", "value")).toString()));
|
assertThat(searchRequestBuilder.toString(), equalTo(new SearchSourceBuilder()
|
||||||
|
.query(QueryBuilders.termQuery("field", "value")).toString()));
|
||||||
String postToString = searchRequestBuilder.request().toString();
|
String postToString = searchRequestBuilder.request().toString();
|
||||||
assertThat(preToString, equalTo(postToString));
|
assertThat(preToString, equalTo(postToString));
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,8 +272,10 @@ public abstract class AbstractTermVectorsTestCase extends ESIntegTestCase {
|
||||||
configs.add(config);
|
configs.add(config);
|
||||||
}
|
}
|
||||||
// always adds a test that fails
|
// always adds a test that fails
|
||||||
configs.add(new TestConfig(new TestDoc("doesnt_exist", new TestFieldSetting[]{}, new String[]{}).index("doesn't_exist").alias("doesn't_exist"),
|
configs.add(new TestConfig(new TestDoc("doesnt_exist", new TestFieldSetting[]{}, new String[]{})
|
||||||
new String[]{"doesnt_exist"}, true, true, true).expectedException(org.elasticsearch.index.IndexNotFoundException.class));
|
.index("doesn't_exist").alias("doesn't_exist"),
|
||||||
|
new String[]{"doesnt_exist"}, true, true, true)
|
||||||
|
.expectedException(org.elasticsearch.index.IndexNotFoundException.class));
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
|
@ -401,9 +403,10 @@ public abstract class AbstractTermVectorsTestCase extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TermVectorsRequestBuilder getRequestForConfig(TestConfig config) {
|
protected TermVectorsRequestBuilder getRequestForConfig(TestConfig config) {
|
||||||
return client().prepareTermVectors(randomBoolean() ? config.doc.index : config.doc.alias, config.doc.type, config.doc.id).setPayloads(config.requestPayloads)
|
return client().prepareTermVectors(randomBoolean() ? config.doc.index : config.doc.alias, config.doc.type, config.doc.id)
|
||||||
.setOffsets(config.requestOffsets).setPositions(config.requestPositions).setFieldStatistics(true).setTermStatistics(true)
|
.setPayloads(config.requestPayloads)
|
||||||
.setSelectedFields(config.selectedFields).setRealtime(false);
|
.setOffsets(config.requestOffsets).setPositions(config.requestPositions).setFieldStatistics(true).setTermStatistics(true)
|
||||||
|
.setSelectedFields(config.selectedFields).setRealtime(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Fields getTermVectorsFromLucene(DirectoryReader directoryReader, TestDoc doc) throws IOException {
|
protected Fields getTermVectorsFromLucene(DirectoryReader directoryReader, TestDoc doc) throws IOException {
|
||||||
|
|
|
@ -765,7 +765,8 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
|
||||||
// check overridden by keyword analyzer ...
|
// check overridden by keyword analyzer ...
|
||||||
if (perFieldAnalyzer.containsKey(fieldName)) {
|
if (perFieldAnalyzer.containsKey(fieldName)) {
|
||||||
TermsEnum iterator = terms.iterator();
|
TermsEnum iterator = terms.iterator();
|
||||||
assertThat("Analyzer for " + fieldName + " should have been overridden!", iterator.next().utf8ToString(), equalTo("some text here"));
|
assertThat("Analyzer for " + fieldName + " should have been overridden!",
|
||||||
|
iterator.next().utf8ToString(), equalTo("some text here"));
|
||||||
assertThat(iterator.next(), nullValue());
|
assertThat(iterator.next(), nullValue());
|
||||||
}
|
}
|
||||||
validFields.add(fieldName);
|
validFields.add(fieldName);
|
||||||
|
|
|
@ -118,7 +118,8 @@ public class MultiTermVectorsIT extends AbstractTermVectorsTestCase {
|
||||||
//Version from Lucene index
|
//Version from Lucene index
|
||||||
refresh();
|
refresh();
|
||||||
response = client().prepareMultiTermVectors()
|
response = client().prepareMultiTermVectors()
|
||||||
.add(new TermVectorsRequest(indexOrAlias(), "type1", "1").selectedFields("field").version(Versions.MATCH_ANY).realtime(false))
|
.add(new TermVectorsRequest(indexOrAlias(), "type1", "1").selectedFields("field")
|
||||||
|
.version(Versions.MATCH_ANY).realtime(false))
|
||||||
.add(new TermVectorsRequest(indexOrAlias(), "type1", "1").selectedFields("field").version(1).realtime(false))
|
.add(new TermVectorsRequest(indexOrAlias(), "type1", "1").selectedFields("field").version(1).realtime(false))
|
||||||
.add(new TermVectorsRequest(indexOrAlias(), "type1", "1").selectedFields("field").version(2).realtime(false))
|
.add(new TermVectorsRequest(indexOrAlias(), "type1", "1").selectedFields("field").version(2).realtime(false))
|
||||||
.get();
|
.get();
|
||||||
|
|
|
@ -269,13 +269,14 @@ public class TermVectorsUnitTests extends ESTestCase {
|
||||||
String ftOpts = FieldMapper.termVectorOptionsToString(ft);
|
String ftOpts = FieldMapper.termVectorOptionsToString(ft);
|
||||||
assertThat("with_positions_payloads", equalTo(ftOpts));
|
assertThat("with_positions_payloads", equalTo(ftOpts));
|
||||||
TextFieldMapper.Builder builder = new TextFieldMapper.Builder(null);
|
TextFieldMapper.Builder builder = new TextFieldMapper.Builder(null);
|
||||||
boolean exceptiontrown = false;
|
boolean exceptionThrown = false;
|
||||||
try {
|
try {
|
||||||
TypeParsers.parseTermVector("", ftOpts, builder);
|
TypeParsers.parseTermVector("", ftOpts, builder);
|
||||||
} catch (MapperParsingException e) {
|
} catch (MapperParsingException e) {
|
||||||
exceptiontrown = true;
|
exceptionThrown = true;
|
||||||
}
|
}
|
||||||
assertThat("TypeParsers.parseTermVector should accept string with_positions_payloads but does not.", exceptiontrown, equalTo(false));
|
assertThat("TypeParsers.parseTermVector should accept string with_positions_payloads but does not.",
|
||||||
|
exceptionThrown, equalTo(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTermVectorStringGenerationWithoutPositions() throws Exception {
|
public void testTermVectorStringGenerationWithoutPositions() throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue