use of org.elasticsearch.action.termvectors.MultiTermVectorsRequest in project elasticsearch by elastic.
the class RestMultiTermVectorsAction method prepareRequest.
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
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")));
request.withContentOrSourceParamParserOrNull(p -> multiTermVectorsRequest.add(template, p));
return channel -> client.multiTermVectors(multiTermVectorsRequest, new RestToXContentListener<MultiTermVectorsResponse>(channel));
}
use of org.elasticsearch.action.termvectors.MultiTermVectorsRequest in project elasticsearch by elastic.
the class MoreLikeThisQueryBuilderTests method executeMultiTermVectors.
@Override
protected MultiTermVectorsResponse executeMultiTermVectors(MultiTermVectorsRequest mtvRequest) {
try {
MultiTermVectorsItemResponse[] responses = new MultiTermVectorsItemResponse[mtvRequest.size()];
int i = 0;
for (TermVectorsRequest request : mtvRequest) {
TermVectorsResponse response = new TermVectorsResponse(request.index(), request.type(), request.id());
response.setExists(true);
Fields generatedFields;
if (request.doc() != null) {
generatedFields = generateFields(randomFields, request.doc().utf8ToString());
} else {
generatedFields = generateFields(request.selectedFields().toArray(new String[request.selectedFields().size()]), request.id());
}
EnumSet<TermVectorsRequest.Flag> flags = EnumSet.of(TermVectorsRequest.Flag.Positions, TermVectorsRequest.Flag.Offsets);
response.setFields(generatedFields, request.selectedFields(), flags, generatedFields);
responses[i++] = new MultiTermVectorsItemResponse(response, null);
}
return new MultiTermVectorsResponse(responses);
} catch (IOException ex) {
throw new ElasticsearchException("boom", ex);
}
}
use of org.elasticsearch.action.termvectors.MultiTermVectorsRequest in project elasticsearch by elastic.
the class IndicesRequestIT method testMultiTermVector.
public void testMultiTermVector() {
String multiTermVectorsShardAction = MultiTermVectorsAction.NAME + "[shard][s]";
interceptTransportActions(multiTermVectorsShardAction);
List<String> indices = new ArrayList<>();
MultiTermVectorsRequest multiTermVectorsRequest = new MultiTermVectorsRequest();
int numDocs = iterations(1, 30);
for (int i = 0; i < numDocs; i++) {
String indexOrAlias = randomIndexOrAlias();
multiTermVectorsRequest.add(indexOrAlias, "type", Integer.toString(i));
indices.add(indexOrAlias);
}
internalCluster().coordOnlyNodeClient().multiTermVectors(multiTermVectorsRequest).actionGet();
clearInterceptedActions();
assertIndicesSubset(indices, multiTermVectorsShardAction);
}
Aggregations