本文整理汇总了Java中org.elasticsearch.rest.action.support.RestActions类的典型用法代码示例。如果您正苦于以下问题:Java RestActions类的具体用法?Java RestActions怎么用?Java RestActions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RestActions类属于org.elasticsearch.rest.action.support包,在下文中一共展示了RestActions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: handleRequest
import org.elasticsearch.rest.action.support.RestActions; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception {
MultiGetRequest multiGetRequest = new MultiGetRequest();
multiGetRequest.refresh(request.paramAsBoolean("refresh", multiGetRequest.refresh()));
multiGetRequest.preference(request.param("preference"));
multiGetRequest.realtime(request.paramAsBoolean("realtime", null));
multiGetRequest.ignoreErrorsOnGeneratedFields(request.paramAsBoolean("ignore_errors_on_generated_fields", false));
String[] sFields = null;
String sField = request.param("fields");
if (sField != null) {
sFields = Strings.splitStringByCommaToArray(sField);
}
FetchSourceContext defaultFetchSource = FetchSourceContext.parseFromRestRequest(request);
multiGetRequest.add(request.param("index"), request.param("type"), sFields, defaultFetchSource, request.param("routing"), RestActions.getRestContent(request), allowExplicitIndex);
client.multiGet(multiGetRequest, new RestToXContentListener<MultiGetResponse>(channel));
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:20,代码来源:RestMultiGetAction.java
示例2: parseExistingDocPercolate
import org.elasticsearch.rest.action.support.RestActions; //导入依赖的package包/类
void parseExistingDocPercolate(PercolateRequest percolateRequest, RestRequest restRequest, RestChannel restChannel, final Client client) {
String index = restRequest.param("index");
String type = restRequest.param("type");
percolateRequest.indices(Strings.splitStringByCommaToArray(restRequest.param("percolate_index", index)));
percolateRequest.documentType(restRequest.param("percolate_type", type));
GetRequest getRequest = new GetRequest(index, type,
restRequest.param("id"));
getRequest.routing(restRequest.param("routing"));
getRequest.preference(restRequest.param("preference"));
getRequest.refresh(restRequest.paramAsBoolean("refresh", getRequest.refresh()));
getRequest.realtime(restRequest.paramAsBoolean("realtime", null));
getRequest.version(RestActions.parseVersion(restRequest));
getRequest.versionType(VersionType.fromString(restRequest.param("version_type"), getRequest.versionType()));
percolateRequest.getRequest(getRequest);
percolateRequest.routing(restRequest.param("percolate_routing"));
percolateRequest.preference(restRequest.param("percolate_preference"));
percolateRequest.source(RestActions.getRestContent(restRequest));
percolateRequest.indicesOptions(IndicesOptions.fromRequest(restRequest, percolateRequest.indicesOptions()));
executePercolate(percolateRequest, restChannel, client);
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:24,代码来源:RestPercolateAction.java
示例3: handleRequest
import org.elasticsearch.rest.action.support.RestActions; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
String scrollIds = request.param("scroll_id");
ClearScrollRequest clearRequest = new ClearScrollRequest();
clearRequest.setScrollIds(Arrays.asList(splitScrollIds(scrollIds)));
if (RestActions.hasBodyContent(request)) {
XContentType type = RestActions.guessBodyContentType(request);
if (type == null) {
scrollIds = RestActions.getRestContent(request).toUtf8();
clearRequest.setScrollIds(Arrays.asList(splitScrollIds(scrollIds)));
} else {
// NOTE: if rest request with xcontent body has request parameters, these parameters does not override xcontent value
clearRequest.setScrollIds(null);
buildFromContent(RestActions.getRestContent(request), clearRequest);
}
}
client.clearScroll(clearRequest, new RestStatusToXContentListener<ClearScrollResponse>(channel));
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:20,代码来源:RestClearScrollAction.java
示例4: handleRequest
import org.elasticsearch.rest.action.support.RestActions; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
String scrollId = request.param("scroll_id");
SearchScrollRequest searchScrollRequest = new SearchScrollRequest();
searchScrollRequest.scrollId(scrollId);
String scroll = request.param("scroll");
if (scroll != null) {
searchScrollRequest.scroll(new Scroll(parseTimeValue(scroll, null, "scroll")));
}
if (RestActions.hasBodyContent(request)) {
XContentType type = XContentFactory.xContentType(RestActions.getRestContent(request));
if (type == null) {
if (scrollId == null) {
scrollId = RestActions.getRestContent(request).toUtf8();
searchScrollRequest.scrollId(scrollId);
}
} else {
// NOTE: if rest request with xcontent body has request parameters, these parameters override xcontent values
buildFromContent(RestActions.getRestContent(request), searchScrollRequest);
}
}
client.searchScroll(searchScrollRequest, new RestStatusToXContentListener<SearchResponse>(channel));
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:RestSearchScrollAction.java
示例5: readURIParameters
import org.elasticsearch.rest.action.support.RestActions; //导入依赖的package包/类
static public void readURIParameters(TermVectorsRequest termVectorsRequest, RestRequest request) {
String fields = request.param("fields");
addFieldStringsFromParameter(termVectorsRequest, fields);
termVectorsRequest.offsets(request.paramAsBoolean("offsets", termVectorsRequest.offsets()));
termVectorsRequest.positions(request.paramAsBoolean("positions", termVectorsRequest.positions()));
termVectorsRequest.payloads(request.paramAsBoolean("payloads", termVectorsRequest.payloads()));
termVectorsRequest.routing(request.param("routing"));
termVectorsRequest.realtime(request.paramAsBoolean("realtime", null));
termVectorsRequest.version(RestActions.parseVersion(request, termVectorsRequest.version()));
termVectorsRequest.versionType(VersionType.fromString(request.param("version_type"), termVectorsRequest.versionType()));
termVectorsRequest.parent(request.param("parent"));
termVectorsRequest.preference(request.param("preference"));
termVectorsRequest.termStatistics(request.paramAsBoolean("termStatistics", termVectorsRequest.termStatistics()));
termVectorsRequest.termStatistics(request.paramAsBoolean("term_statistics", termVectorsRequest.termStatistics()));
termVectorsRequest.fieldStatistics(request.paramAsBoolean("fieldStatistics", termVectorsRequest.fieldStatistics()));
termVectorsRequest.fieldStatistics(request.paramAsBoolean("field_statistics", termVectorsRequest.fieldStatistics()));
termVectorsRequest.dfs(request.paramAsBoolean("dfs", termVectorsRequest.dfs()));
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:19,代码来源:RestTermVectorsAction.java
示例6: doRequest
import org.elasticsearch.rest.action.support.RestActions; //导入依赖的package包/类
@Override
public void doRequest(final RestRequest request, final RestChannel channel, final Client client) {
String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
CountRequest countRequest = new CountRequest(indices);
String source = request.param("source");
if (source != null) {
countRequest.source(source);
} else {
QuerySourceBuilder querySourceBuilder = RestActions.parseQuerySource(request);
if (querySourceBuilder != null) {
countRequest.source(querySourceBuilder);
}
}
client.search(countRequest.toSearchRequest(), new RestResponseListener<SearchResponse>(channel) {
@Override
public RestResponse buildResponse(SearchResponse countResponse) throws Exception {
return RestTable.buildResponse(buildTable(request, countResponse), channel);
}
});
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:RestCountAction.java
示例7: handleRequest
import org.elasticsearch.rest.action.support.RestActions; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
final ExistsRequest existsRequest = new ExistsRequest(Strings.splitStringByCommaToArray(request.param("index")));
existsRequest.indicesOptions(IndicesOptions.fromRequest(request, existsRequest.indicesOptions()));
if (RestActions.hasBodyContent(request)) {
existsRequest.source(RestActions.getRestContent(request));
} else {
QuerySourceBuilder querySourceBuilder = RestActions.parseQuerySource(request);
if (querySourceBuilder != null) {
existsRequest.source(querySourceBuilder);
}
}
existsRequest.routing(request.param("routing"));
existsRequest.minScore(request.paramAsFloat("min_score", DEFAULT_MIN_SCORE));
existsRequest.types(Strings.splitStringByCommaToArray(request.param("type")));
existsRequest.preference(request.param("preference"));
client.exists(existsRequest, new RestBuilderListener<ExistsResponse>(channel) {
@Override
public RestResponse buildResponse(ExistsResponse response, XContentBuilder builder) throws Exception {
RestStatus status = response.exists() ? OK : NOT_FOUND;
builder.startObject();
builder.field("exists", response.exists());
builder.endObject();
return new BytesRestResponse(status, builder);
}
});
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:29,代码来源:RestExistsAction.java
示例8: handleRequest
import org.elasticsearch.rest.action.support.RestActions; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
CountRequest countRequest = new CountRequest(Strings.splitStringByCommaToArray(request.param("index")));
countRequest.indicesOptions(IndicesOptions.fromRequest(request, countRequest.indicesOptions()));
if (RestActions.hasBodyContent(request)) {
countRequest.source(RestActions.getRestContent(request));
} else {
QuerySourceBuilder querySourceBuilder = RestActions.parseQuerySource(request);
if (querySourceBuilder != null) {
countRequest.source(querySourceBuilder);
}
}
countRequest.routing(request.param("routing"));
countRequest.minScore(request.paramAsFloat("min_score", DEFAULT_MIN_SCORE));
countRequest.types(Strings.splitStringByCommaToArray(request.param("type")));
countRequest.preference(request.param("preference"));
final int terminateAfter = request.paramAsInt("terminate_after", DEFAULT_TERMINATE_AFTER);
if (terminateAfter < 0) {
throw new IllegalArgumentException("terminateAfter must be > 0");
} else if (terminateAfter > 0) {
countRequest.terminateAfter(terminateAfter);
}
client.search(countRequest.toSearchRequest(), new RestBuilderListener<SearchResponse>(channel) {
@Override
public RestResponse buildResponse(SearchResponse response, XContentBuilder builder) throws Exception {
builder.startObject();
if (terminateAfter != DEFAULT_TERMINATE_AFTER) {
builder.field("terminated_early", response.isTerminatedEarly());
}
builder.field("count", response.getHits().totalHits());
buildBroadcastShardsHeader(builder, request, response.getTotalShards(), response.getSuccessfulShards(),
response.getFailedShards(), response.getShardFailures());
builder.endObject();
return new BytesRestResponse(response.status(), builder);
}
});
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:40,代码来源:RestCountAction.java
示例9: handleRequest
import org.elasticsearch.rest.action.support.RestActions; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
String[] texts = request.paramAsStringArrayOrEmptyIfAll("text");
AnalyzeRequest analyzeRequest = new AnalyzeRequest(request.param("index"));
analyzeRequest.text(texts);
analyzeRequest.analyzer(request.param("analyzer"));
analyzeRequest.field(request.param("field"));
analyzeRequest.tokenizer(request.param("tokenizer"));
analyzeRequest.tokenFilters(request.paramAsStringArray("filter", request.paramAsStringArray("token_filter",
request.paramAsStringArray("token_filters", request.paramAsStringArray("filters", analyzeRequest.tokenFilters())))));
analyzeRequest.charFilters(request.paramAsStringArray("char_filter", request.paramAsStringArray("char_filters", analyzeRequest.charFilters())));
analyzeRequest.explain(request.paramAsBoolean("explain", false));
analyzeRequest.attributes(request.paramAsStringArray("attributes", analyzeRequest.attributes()));
if (RestActions.hasBodyContent(request)) {
XContentType type = RestActions.guessBodyContentType(request);
if (type == null) {
if (texts == null || texts.length == 0) {
texts = new String[]{ RestActions.getRestContent(request).toUtf8() };
analyzeRequest.text(texts);
}
} else {
// NOTE: if rest request with xcontent body has request parameters, the parameters does not override xcontent values
buildFromContent(RestActions.getRestContent(request), analyzeRequest, parseFieldMatcher);
}
}
client.admin().indices().analyze(analyzeRequest, new RestToXContentListener<AnalyzeResponse>(channel));
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:32,代码来源:RestAnalyzeAction.java
示例10: handleRequest
import org.elasticsearch.rest.action.support.RestActions; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception {
if (RestActions.hasBodyContent(request) && request.hasParam("fields")) {
throw new IllegalArgumentException("can't specify a request body and [fields] request parameter, either specify a request body or the [fields] request parameter");
}
final FieldStatsRequest fieldStatsRequest = new FieldStatsRequest();
fieldStatsRequest.indices(Strings.splitStringByCommaToArray(request.param("index")));
fieldStatsRequest.indicesOptions(IndicesOptions.fromRequest(request, fieldStatsRequest.indicesOptions()));
fieldStatsRequest.level(request.param("level", FieldStatsRequest.DEFAULT_LEVEL));
if (RestActions.hasBodyContent(request)) {
fieldStatsRequest.source(RestActions.getRestContent(request));
} else {
fieldStatsRequest.setFields(Strings.splitStringByCommaToArray(request.param("fields")));
}
client.fieldStats(fieldStatsRequest, new RestBuilderListener<FieldStatsResponse>(channel) {
@Override
public RestResponse buildResponse(FieldStatsResponse response, XContentBuilder builder) throws Exception {
builder.startObject();
buildBroadcastShardsHeader(builder, request, response);
builder.startObject("indices");
for (Map.Entry<String, Map<String, FieldStats>> entry1 : response.getIndicesMergedFieldStats().entrySet()) {
builder.startObject(entry1.getKey());
builder.startObject("fields");
for (Map.Entry<String, FieldStats> entry2 : entry1.getValue().entrySet()) {
builder.field(entry2.getKey());
entry2.getValue().toXContent(builder, request);
}
builder.endObject();
builder.endObject();
}
builder.endObject();
return new BytesRestResponse(RestStatus.OK, builder);
}
});
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:39,代码来源:RestFieldStatsAction.java
示例11: handleRequest
import org.elasticsearch.rest.action.support.RestActions; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
final GetRequest getRequest = new GetRequest(request.param("index"), request.param("type"), request.param("id"));
getRequest.operationThreaded(true);
getRequest.refresh(request.paramAsBoolean("refresh", getRequest.refresh()));
getRequest.routing(request.param("routing")); // order is important, set it after routing, so it will set the routing
getRequest.parent(request.param("parent"));
getRequest.preference(request.param("preference"));
getRequest.realtime(request.paramAsBoolean("realtime", null));
getRequest.ignoreErrorsOnGeneratedFields(request.paramAsBoolean("ignore_errors_on_generated_fields", false));
String sField = request.param("fields");
if (sField != null) {
String[] sFields = Strings.splitStringByCommaToArray(sField);
if (sFields != null) {
getRequest.fields(sFields);
}
}
getRequest.version(RestActions.parseVersion(request));
getRequest.versionType(VersionType.fromString(request.param("version_type"), getRequest.versionType()));
getRequest.fetchSourceContext(FetchSourceContext.parseFromRestRequest(request));
client.get(getRequest, new RestBuilderListener<GetResponse>(channel) {
@Override
public RestResponse buildResponse(GetResponse response, XContentBuilder builder) throws Exception {
builder.startObject();
response.toXContent(builder, request);
builder.endObject();
if (!response.isExists()) {
return new BytesRestResponse(NOT_FOUND, builder);
} else {
return new BytesRestResponse(OK, builder);
}
}
});
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:39,代码来源:RestGetAction.java
示例12: handleRequest
import org.elasticsearch.rest.action.support.RestActions; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest restRequest, final RestChannel restChannel, final Client client) throws Exception {
MultiPercolateRequest multiPercolateRequest = new MultiPercolateRequest();
multiPercolateRequest.indicesOptions(IndicesOptions.fromRequest(restRequest, multiPercolateRequest.indicesOptions()));
multiPercolateRequest.indices(Strings.splitStringByCommaToArray(restRequest.param("index")));
multiPercolateRequest.documentType(restRequest.param("type"));
multiPercolateRequest.add(RestActions.getRestContent(restRequest), allowExplicitIndex);
client.multiPercolate(multiPercolateRequest, new RestToXContentListener<MultiPercolateResponse>(restChannel));
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:RestMultiPercolateAction.java
示例13: parseDocPercolate
import org.elasticsearch.rest.action.support.RestActions; //导入依赖的package包/类
void parseDocPercolate(PercolateRequest percolateRequest, RestRequest restRequest, RestChannel restChannel, final Client client) {
percolateRequest.indices(Strings.splitStringByCommaToArray(restRequest.param("index")));
percolateRequest.documentType(restRequest.param("type"));
percolateRequest.routing(restRequest.param("routing"));
percolateRequest.preference(restRequest.param("preference"));
percolateRequest.source(RestActions.getRestContent(restRequest));
percolateRequest.indicesOptions(IndicesOptions.fromRequest(restRequest, percolateRequest.indicesOptions()));
executePercolate(percolateRequest, restChannel, client);
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:RestPercolateAction.java
示例14: handleRequest
import org.elasticsearch.rest.action.support.RestActions; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
DeleteRequest deleteRequest = new DeleteRequest(request.param("index"), request.param("type"), request.param("id"));
deleteRequest.routing(request.param("routing"));
deleteRequest.parent(request.param("parent")); // order is important, set it after routing, so it will set the routing
deleteRequest.timeout(request.paramAsTime("timeout", DeleteRequest.DEFAULT_TIMEOUT));
deleteRequest.refresh(request.paramAsBoolean("refresh", deleteRequest.refresh()));
deleteRequest.version(RestActions.parseVersion(request));
deleteRequest.versionType(VersionType.fromString(request.param("version_type"), deleteRequest.versionType()));
String consistencyLevel = request.param("consistency");
if (consistencyLevel != null) {
deleteRequest.consistencyLevel(WriteConsistencyLevel.fromString(consistencyLevel));
}
client.delete(deleteRequest, new RestBuilderListener<DeleteResponse>(channel) {
@Override
public RestResponse buildResponse(DeleteResponse result, XContentBuilder builder) throws Exception {
ActionWriteResponse.ShardInfo shardInfo = result.getShardInfo();
builder.startObject().field(Fields.FOUND, result.isFound())
.field(Fields._INDEX, result.getIndex())
.field(Fields._TYPE, result.getType())
.field(Fields._ID, result.getId())
.field(Fields._VERSION, result.getVersion())
.value(shardInfo)
.endObject();
RestStatus status = shardInfo.status();
if (!result.isFound()) {
status = NOT_FOUND;
}
return new BytesRestResponse(status, builder);
}
});
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:35,代码来源:RestDeleteAction.java
示例15: handleRequest
import org.elasticsearch.rest.action.support.RestActions; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception {
MultiSearchRequest multiSearchRequest = new MultiSearchRequest();
String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
String[] types = Strings.splitStringByCommaToArray(request.param("type"));
String path = request.path();
boolean isTemplateRequest = isTemplateRequest(path);
IndicesOptions indicesOptions = IndicesOptions.fromRequest(request, multiSearchRequest.indicesOptions());
multiSearchRequest.add(RestActions.getRestContent(request), isTemplateRequest, indices, types, request.param("search_type"), request.param("routing"), indicesOptions, allowExplicitIndex);
client.multiSearch(multiSearchRequest, new RestToXContentListener<MultiSearchResponse>(channel));
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:14,代码来源:RestMultiSearchAction.java
示例16: handleRequest
import org.elasticsearch.rest.action.support.RestActions; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception {
TermVectorsRequest termVectorsRequest = new TermVectorsRequest(request.param("index"), request.param("type"), request.param("id"));
if (RestActions.hasBodyContent(request)) {
try (XContentParser parser = XContentFactory.xContent(RestActions.guessBodyContentType(request)).createParser(RestActions.getRestContent(request))){
TermVectorsRequest.parseRequest(termVectorsRequest, parser);
}
}
readURIParameters(termVectorsRequest, request);
client.termVectors(termVectorsRequest, new RestToXContentListener<TermVectorsResponse>(channel));
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:RestTermVectorsAction.java
示例17: handleRequest
import org.elasticsearch.rest.action.support.RestActions; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception {
MultiTermVectorsRequest multiTermVectorsRequest = new MultiTermVectorsRequest();
TermVectorsRequest template = new TermVectorsRequest();
template.index(request.param("index"));
template.type(request.param("type"));
RestTermVectorsAction.readURIParameters(template, request);
multiTermVectorsRequest.ids(Strings.commaDelimitedListToStringArray(request.param("ids")));
multiTermVectorsRequest.add(template, RestActions.getRestContent(request));
client.multiTermVectors(multiTermVectorsRequest, new RestToXContentListener<MultiTermVectorsResponse>(channel));
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:RestMultiTermVectorsAction.java
示例18: toXContent
import org.elasticsearch.rest.action.support.RestActions; //导入依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
if (scrollId != null) {
builder.field(Fields._SCROLL_ID, scrollId);
}
builder.field(Fields.TOOK, tookInMillis);
builder.field(Fields.TIMED_OUT, isTimedOut());
if (isTerminatedEarly() != null) {
builder.field(Fields.TERMINATED_EARLY, isTerminatedEarly());
}
RestActions.buildBroadcastShardsHeader(builder, params, getTotalShards(), getSuccessfulShards(), getFailedShards(), getShardFailures());
internalResponse.toXContent(builder, params);
return builder;
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:15,代码来源:SearchResponse.java
示例19: handleRequest
import org.elasticsearch.rest.action.support.RestActions; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception {
MultiSearchRequest multiSearchRequest = new MultiSearchRequest();
String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
String[] types = Strings.splitStringByCommaToArray(request.param("type"));
String path = request.path();
boolean isTemplateRequest = isTemplateRequest(path);
IndicesOptions indicesOptions = IndicesOptions.fromRequest(request, multiSearchRequest.indicesOptions());
multiSearchRequest.add(RestActions.getRestContent(request), isTemplateRequest, indices, types, request.param("search_type"), request.param("routing"), indicesOptions, allowExplicitIndex);
client.execute(CoordinateMultiSearchAction.INSTANCE, multiSearchRequest, new RestToXContentListener<MultiSearchResponse>(channel));
}
开发者ID:sirensolutions,项目名称:siren-join,代码行数:14,代码来源:RestCoordinateMultiSearchAction.java
示例20: toMultiSearchRequest
import org.elasticsearch.rest.action.support.RestActions; //导入依赖的package包/类
protected MultiSearchRequest toMultiSearchRequest(final RestRequest request) throws Exception {
final MultiGetRequest multiGetRequest = new MultiGetRequest();
multiGetRequest.refresh(request.paramAsBoolean("refresh", multiGetRequest.refresh()));
multiGetRequest.preference(request.param("preference"));
multiGetRequest.realtime(request.paramAsBoolean("realtime", null));
multiGetRequest.ignoreErrorsOnGeneratedFields(request.paramAsBoolean("ignore_errors_on_generated_fields", false));
String[] sFields = null;
final String sField = request.param("fields");
if (sField != null) {
sFields = Strings.splitStringByCommaToArray(sField);
}
final FetchSourceContext defaultFetchSource = FetchSourceContext.parseFromRestRequest(request);
multiGetRequest.add(request.param("index"), request.param("type"), sFields, defaultFetchSource, request.param("routing"),
RestActions.getRestContent(request),
settings.getAsBoolean(AbstractACRestFilter.REST_ACTION_MULTI_ALLOW_EXPLICIT_INDEX, true));
final MultiSearchRequest msearch = new MultiSearchRequest();
msearch.copyContextFrom(request);
for (final Iterator<Item> iterator = multiGetRequest.iterator(); iterator.hasNext();) {
final Item item = iterator.next();
final SearchRequest st = new SearchRequest();
st.routing(item.routing());
st.indices(item.indices());
st.types(item.type());
st.preference(request.param("preference"));
st.source(SearchSourceBuilder.searchSource().query(new IdsQueryBuilder(item.type()).addIds(item.id())));
msearch.add(st);
}
return msearch;
}
开发者ID:petalmd,项目名称:armor,代码行数:38,代码来源:AbstractACRestFilter.java
注:本文中的org.elasticsearch.rest.action.support.RestActions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论