mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-01 16:39:11 +00:00
Fixing some tests and compile problems in reindex module
This commit is contained in:
parent
5a8d40e44a
commit
bbcbba1bf5
@ -93,6 +93,7 @@ import org.elasticsearch.plugins.Plugin;
|
|||||||
import org.elasticsearch.script.Script;
|
import org.elasticsearch.script.Script;
|
||||||
import org.elasticsearch.script.groovy.GroovyPlugin;
|
import org.elasticsearch.script.groovy.GroovyPlugin;
|
||||||
import org.elasticsearch.search.action.SearchTransportService;
|
import org.elasticsearch.search.action.SearchTransportService;
|
||||||
|
import org.elasticsearch.search.suggest.SuggestBuilder;
|
||||||
import org.elasticsearch.tasks.Task;
|
import org.elasticsearch.tasks.Task;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||||
@ -445,7 +446,7 @@ public class IndicesRequestTests extends ESIntegTestCase {
|
|||||||
String suggestAction = SuggestAction.NAME + "[s]";
|
String suggestAction = SuggestAction.NAME + "[s]";
|
||||||
interceptTransportActions(suggestAction);
|
interceptTransportActions(suggestAction);
|
||||||
|
|
||||||
SuggestRequest suggestRequest = new SuggestRequest(randomIndicesOrAliases());
|
SuggestRequest suggestRequest = new SuggestRequest(randomIndicesOrAliases()).suggest(new SuggestBuilder());
|
||||||
internalCluster().clientNodeClient().suggest(suggestRequest).actionGet();
|
internalCluster().clientNodeClient().suggest(suggestRequest).actionGet();
|
||||||
|
|
||||||
clearInterceptedActions();
|
clearInterceptedActions();
|
||||||
|
@ -20,6 +20,38 @@
|
|||||||
package org.elasticsearch.messy.tests;
|
package org.elasticsearch.messy.tests;
|
||||||
|
|
||||||
|
|
||||||
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
|
||||||
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
|
||||||
|
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||||
|
import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
|
||||||
|
import static org.elasticsearch.search.suggest.SuggestBuilders.phraseSuggestion;
|
||||||
|
import static org.elasticsearch.search.suggest.SuggestBuilders.termSuggestion;
|
||||||
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||||
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
|
||||||
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSuggestion;
|
||||||
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSuggestionPhraseCollateMatchExists;
|
||||||
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSuggestionSize;
|
||||||
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows;
|
||||||
|
import static org.hamcrest.Matchers.anyOf;
|
||||||
|
import static org.hamcrest.Matchers.endsWith;
|
||||||
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
import static org.hamcrest.Matchers.instanceOf;
|
||||||
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchException;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
|
import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
|
||||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||||
@ -49,38 +81,6 @@ import org.elasticsearch.search.suggest.term.TermSuggestionBuilder.SuggestMode;
|
|||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
import org.elasticsearch.test.hamcrest.ElasticsearchAssertions;
|
import org.elasticsearch.test.hamcrest.ElasticsearchAssertions;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
|
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
|
|
||||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
|
||||||
import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
|
|
||||||
import static org.elasticsearch.search.suggest.SuggestBuilders.phraseSuggestion;
|
|
||||||
import static org.elasticsearch.search.suggest.SuggestBuilders.termSuggestion;
|
|
||||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
|
||||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
|
|
||||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSuggestion;
|
|
||||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSuggestionPhraseCollateMatchExists;
|
|
||||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSuggestionSize;
|
|
||||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows;
|
|
||||||
import static org.hamcrest.Matchers.anyOf;
|
|
||||||
import static org.hamcrest.Matchers.endsWith;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
|
||||||
import static org.hamcrest.Matchers.instanceOf;
|
|
||||||
import static org.hamcrest.Matchers.nullValue;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration tests for term and phrase suggestions. Many of these tests many requests that vary only slightly from one another. Where
|
* Integration tests for term and phrase suggestions. Many of these tests many requests that vary only slightly from one another. Where
|
||||||
* possible these tests should declare for the first request, make the request, modify the configuration for the next request, make that
|
* possible these tests should declare for the first request, make the request, modify the configuration for the next request, make that
|
||||||
@ -343,7 +343,7 @@ public class SuggestSearchTests extends ESIntegTestCase {
|
|||||||
createIndex("test");
|
createIndex("test");
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
index("test", "type1", "1", "foo", "bar");
|
index("test", "type1", "1", "text", "bar");
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
TermSuggestionBuilder termSuggest = termSuggestion("text")
|
TermSuggestionBuilder termSuggest = termSuggestion("text")
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package org.elasticsearch.index.reindex;
|
package org.elasticsearch.index.reindex;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionRequest;
|
import org.elasticsearch.action.ActionRequest;
|
||||||
import org.elasticsearch.action.ActionRequestValidationException;
|
import org.elasticsearch.action.ActionRequestValidationException;
|
||||||
import org.elasticsearch.action.support.TransportAction;
|
import org.elasticsearch.action.support.TransportAction;
|
||||||
@ -33,23 +35,25 @@ import org.elasticsearch.rest.RestChannel;
|
|||||||
import org.elasticsearch.rest.RestRequest;
|
import org.elasticsearch.rest.RestRequest;
|
||||||
import org.elasticsearch.rest.RestStatus;
|
import org.elasticsearch.rest.RestStatus;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorParsers;
|
import org.elasticsearch.search.aggregations.AggregatorParsers;
|
||||||
|
import org.elasticsearch.search.suggest.Suggesters;
|
||||||
import org.elasticsearch.tasks.LoggingTaskListener;
|
import org.elasticsearch.tasks.LoggingTaskListener;
|
||||||
import org.elasticsearch.tasks.Task;
|
import org.elasticsearch.tasks.Task;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public abstract class AbstractBaseReindexRestHandler<Request extends ActionRequest<Request>, Response extends BulkIndexByScrollResponse,
|
public abstract class AbstractBaseReindexRestHandler<Request extends ActionRequest<Request>, Response extends BulkIndexByScrollResponse,
|
||||||
TA extends TransportAction<Request, Response>> extends BaseRestHandler {
|
TA extends TransportAction<Request, Response>> extends BaseRestHandler {
|
||||||
protected final IndicesQueriesRegistry indicesQueriesRegistry;
|
protected final IndicesQueriesRegistry indicesQueriesRegistry;
|
||||||
protected final AggregatorParsers aggParsers;
|
protected final AggregatorParsers aggParsers;
|
||||||
|
protected final Suggesters suggesters;
|
||||||
private final ClusterService clusterService;
|
private final ClusterService clusterService;
|
||||||
private final TA action;
|
private final TA action;
|
||||||
|
|
||||||
protected AbstractBaseReindexRestHandler(Settings settings, Client client,
|
protected AbstractBaseReindexRestHandler(Settings settings, Client client,
|
||||||
IndicesQueriesRegistry indicesQueriesRegistry, AggregatorParsers aggParsers, ClusterService clusterService, TA action) {
|
IndicesQueriesRegistry indicesQueriesRegistry, AggregatorParsers aggParsers, Suggesters suggesters,
|
||||||
|
ClusterService clusterService, TA action) {
|
||||||
super(settings, client);
|
super(settings, client);
|
||||||
this.indicesQueriesRegistry = indicesQueriesRegistry;
|
this.indicesQueriesRegistry = indicesQueriesRegistry;
|
||||||
this.aggParsers = aggParsers;
|
this.aggParsers = aggParsers;
|
||||||
|
this.suggesters = suggesters;
|
||||||
this.clusterService = clusterService;
|
this.clusterService = clusterService;
|
||||||
this.action = action;
|
this.action = action;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,14 @@
|
|||||||
|
|
||||||
package org.elasticsearch.index.reindex;
|
package org.elasticsearch.index.reindex;
|
||||||
|
|
||||||
|
import static org.elasticsearch.common.unit.TimeValue.parseTimeValue;
|
||||||
|
import static org.elasticsearch.rest.RestRequest.Method.POST;
|
||||||
|
import static org.elasticsearch.rest.RestStatus.BAD_REQUEST;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.elasticsearch.action.WriteConsistencyLevel;
|
import org.elasticsearch.action.WriteConsistencyLevel;
|
||||||
import org.elasticsearch.action.index.IndexRequest;
|
import org.elasticsearch.action.index.IndexRequest;
|
||||||
import org.elasticsearch.action.search.SearchRequest;
|
import org.elasticsearch.action.search.SearchRequest;
|
||||||
@ -43,14 +51,7 @@ import org.elasticsearch.rest.RestController;
|
|||||||
import org.elasticsearch.rest.RestRequest;
|
import org.elasticsearch.rest.RestRequest;
|
||||||
import org.elasticsearch.script.Script;
|
import org.elasticsearch.script.Script;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorParsers;
|
import org.elasticsearch.search.aggregations.AggregatorParsers;
|
||||||
|
import org.elasticsearch.search.suggest.Suggesters;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static org.elasticsearch.common.unit.TimeValue.parseTimeValue;
|
|
||||||
import static org.elasticsearch.rest.RestRequest.Method.POST;
|
|
||||||
import static org.elasticsearch.rest.RestStatus.BAD_REQUEST;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expose IndexBySearchRequest over rest.
|
* Expose IndexBySearchRequest over rest.
|
||||||
@ -76,7 +77,7 @@ public class RestReindexAction extends AbstractBaseReindexRestHandler<ReindexReq
|
|||||||
builder.map(source);
|
builder.map(source);
|
||||||
parser = parser.contentType().xContent().createParser(builder.bytes());
|
parser = parser.contentType().xContent().createParser(builder.bytes());
|
||||||
context.queryParseContext.reset(parser);
|
context.queryParseContext.reset(parser);
|
||||||
search.source().parseXContent(parser, context.queryParseContext, context.aggParsers);
|
search.source().parseXContent(parser, context.queryParseContext, context.aggParsers, context.suggesters);
|
||||||
};
|
};
|
||||||
|
|
||||||
ObjectParser<IndexRequest, Void> destParser = new ObjectParser<>("dest");
|
ObjectParser<IndexRequest, Void> destParser = new ObjectParser<>("dest");
|
||||||
@ -102,9 +103,9 @@ public class RestReindexAction extends AbstractBaseReindexRestHandler<ReindexReq
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public RestReindexAction(Settings settings, RestController controller, Client client,
|
public RestReindexAction(Settings settings, RestController controller, Client client,
|
||||||
IndicesQueriesRegistry indicesQueriesRegistry, AggregatorParsers aggParsers, ClusterService clusterService,
|
IndicesQueriesRegistry indicesQueriesRegistry, AggregatorParsers aggParsers, Suggesters suggesters,
|
||||||
TransportReindexAction action) {
|
ClusterService clusterService, TransportReindexAction action) {
|
||||||
super(settings, client, indicesQueriesRegistry, aggParsers, clusterService, action);
|
super(settings, client, indicesQueriesRegistry, aggParsers, suggesters, clusterService, action);
|
||||||
controller.registerHandler(POST, "/_reindex", this);
|
controller.registerHandler(POST, "/_reindex", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +119,8 @@ public class RestReindexAction extends AbstractBaseReindexRestHandler<ReindexReq
|
|||||||
ReindexRequest internalRequest = new ReindexRequest(new SearchRequest(), new IndexRequest());
|
ReindexRequest internalRequest = new ReindexRequest(new SearchRequest(), new IndexRequest());
|
||||||
|
|
||||||
try (XContentParser xcontent = XContentFactory.xContent(request.content()).createParser(request.content())) {
|
try (XContentParser xcontent = XContentFactory.xContent(request.content()).createParser(request.content())) {
|
||||||
PARSER.parse(xcontent, internalRequest, new ReindexParseContext(new QueryParseContext(indicesQueriesRegistry), aggParsers));
|
PARSER.parse(xcontent, internalRequest, new ReindexParseContext(new QueryParseContext(indicesQueriesRegistry), aggParsers,
|
||||||
|
suggesters));
|
||||||
} catch (ParsingException e) {
|
} catch (ParsingException e) {
|
||||||
logger.warn("Bad request", e);
|
logger.warn("Bad request", e);
|
||||||
badRequest(channel, e.getDetailedMessage());
|
badRequest(channel, e.getDetailedMessage());
|
||||||
@ -170,10 +172,13 @@ public class RestReindexAction extends AbstractBaseReindexRestHandler<ReindexReq
|
|||||||
private class ReindexParseContext {
|
private class ReindexParseContext {
|
||||||
private final QueryParseContext queryParseContext;
|
private final QueryParseContext queryParseContext;
|
||||||
private final AggregatorParsers aggParsers;
|
private final AggregatorParsers aggParsers;
|
||||||
|
private final Suggesters suggesters;
|
||||||
|
|
||||||
public ReindexParseContext(QueryParseContext queryParseContext, AggregatorParsers aggParsers) {
|
public ReindexParseContext(QueryParseContext queryParseContext, AggregatorParsers aggParsers,
|
||||||
|
Suggesters suggesters) {
|
||||||
this.queryParseContext = queryParseContext;
|
this.queryParseContext = queryParseContext;
|
||||||
this.aggParsers = aggParsers;
|
this.aggParsers = aggParsers;
|
||||||
|
this.suggesters = suggesters;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,12 @@
|
|||||||
|
|
||||||
package org.elasticsearch.index.reindex;
|
package org.elasticsearch.index.reindex;
|
||||||
|
|
||||||
|
import static org.elasticsearch.index.reindex.AbstractBulkByScrollRequest.SIZE_ALL_MATCHES;
|
||||||
|
import static org.elasticsearch.index.reindex.RestReindexAction.parseCommon;
|
||||||
|
import static org.elasticsearch.rest.RestRequest.Method.POST;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.elasticsearch.action.search.SearchRequest;
|
import org.elasticsearch.action.search.SearchRequest;
|
||||||
import org.elasticsearch.client.Client;
|
import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
@ -38,20 +44,15 @@ import org.elasticsearch.rest.action.search.RestSearchAction;
|
|||||||
import org.elasticsearch.rest.action.support.RestActions;
|
import org.elasticsearch.rest.action.support.RestActions;
|
||||||
import org.elasticsearch.script.Script;
|
import org.elasticsearch.script.Script;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorParsers;
|
import org.elasticsearch.search.aggregations.AggregatorParsers;
|
||||||
|
import org.elasticsearch.search.suggest.Suggesters;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static org.elasticsearch.index.reindex.AbstractBulkByScrollRequest.SIZE_ALL_MATCHES;
|
|
||||||
import static org.elasticsearch.index.reindex.RestReindexAction.parseCommon;
|
|
||||||
import static org.elasticsearch.rest.RestRequest.Method.POST;
|
|
||||||
|
|
||||||
public class RestUpdateByQueryAction extends
|
public class RestUpdateByQueryAction extends
|
||||||
AbstractBaseReindexRestHandler<UpdateByQueryRequest, BulkIndexByScrollResponse, TransportUpdateByQueryAction> {
|
AbstractBaseReindexRestHandler<UpdateByQueryRequest, BulkIndexByScrollResponse, TransportUpdateByQueryAction> {
|
||||||
@Inject
|
@Inject
|
||||||
public RestUpdateByQueryAction(Settings settings, RestController controller, Client client,
|
public RestUpdateByQueryAction(Settings settings, RestController controller, Client client,
|
||||||
IndicesQueriesRegistry indicesQueriesRegistry, AggregatorParsers aggParsers, ClusterService clusterService,
|
IndicesQueriesRegistry indicesQueriesRegistry, AggregatorParsers aggParsers, Suggesters suggesters,
|
||||||
TransportUpdateByQueryAction action) {
|
ClusterService clusterService, TransportUpdateByQueryAction action) {
|
||||||
super(settings, client, indicesQueriesRegistry, aggParsers, clusterService, action);
|
super(settings, client, indicesQueriesRegistry, aggParsers, suggesters, clusterService, action);
|
||||||
controller.registerHandler(POST, "/{index}/_update_by_query", this);
|
controller.registerHandler(POST, "/{index}/_update_by_query", this);
|
||||||
controller.registerHandler(POST, "/{index}/{type}/_update_by_query", this);
|
controller.registerHandler(POST, "/{index}/{type}/_update_by_query", this);
|
||||||
}
|
}
|
||||||
@ -96,7 +97,7 @@ public class RestUpdateByQueryAction extends
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
RestSearchAction.parseSearchRequest(internalRequest.getSearchRequest(), indicesQueriesRegistry, request,
|
RestSearchAction.parseSearchRequest(internalRequest.getSearchRequest(), indicesQueriesRegistry, request,
|
||||||
parseFieldMatcher, aggParsers, bodyContent);
|
parseFieldMatcher, aggParsers, suggesters, bodyContent);
|
||||||
|
|
||||||
String conflicts = request.param("conflicts");
|
String conflicts = request.param("conflicts");
|
||||||
if (conflicts != null) {
|
if (conflicts != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user