use of org.elasticsearch.action.index.IndexRequest in project elasticsearch by elastic.
the class RestReindexActionTests method testReindexFromRemoteRequestParsing.
public void testReindexFromRemoteRequestParsing() throws IOException {
BytesReference request;
try (XContentBuilder b = JsonXContent.contentBuilder()) {
b.startObject();
{
b.startObject("source");
{
b.startObject("remote");
{
b.field("host", "http://localhost:9200");
}
b.endObject();
b.field("index", "source");
}
b.endObject();
b.startObject("dest");
{
b.field("index", "dest");
}
b.endObject();
}
b.endObject();
request = b.bytes();
}
try (XContentParser p = createParser(JsonXContent.jsonXContent, request)) {
ReindexRequest r = new ReindexRequest(new SearchRequest(), new IndexRequest());
RestReindexAction.PARSER.parse(p, r, null);
assertEquals("localhost", r.getRemoteInfo().getHost());
assertArrayEquals(new String[] { "source" }, r.getSearchRequest().indices());
}
}
use of org.elasticsearch.action.index.IndexRequest in project elasticsearch by elastic.
the class ReindexMetadataTests method testRoutingCopiedByDefault.
public void testRoutingCopiedByDefault() throws Exception {
IndexRequest index = new IndexRequest();
action().copyMetadata(AbstractAsyncBulkByScrollAction.wrap(index), doc().setRouting("foo"));
assertEquals("foo", index.routing());
}
use of org.elasticsearch.action.index.IndexRequest in project elasticsearch by elastic.
the class ReindexRequestTests method newRequest.
@Override
protected ReindexRequest newRequest() {
ReindexRequest reindex = new ReindexRequest(new SearchRequest(), new IndexRequest());
reindex.getSearchRequest().indices("source");
reindex.getDestination().index("dest");
return reindex;
}
use of org.elasticsearch.action.index.IndexRequest in project elasticsearch by elastic.
the class ReindexScriptTests method testSetVersion.
public void testSetVersion() throws Exception {
Number version = randomFrom(new Number[] { null, 234, 234L });
IndexRequest index = applyScript((Map<String, Object> ctx) -> ctx.put("_version", version));
if (version == null) {
assertEquals(Versions.MATCH_ANY, index.version());
} else {
assertEquals(version.longValue(), index.version());
}
}
use of org.elasticsearch.action.index.IndexRequest in project elasticsearch by elastic.
the class ReindexScriptTests method testSetType.
public void testSetType() throws Exception {
Object type = randomFrom(new Object[] { 234, 234L, "pancake" });
IndexRequest index = applyScript((Map<String, Object> ctx) -> ctx.put("_type", type));
assertEquals(type.toString(), index.type());
}
Aggregations