use of org.opensearch.action.ingest.PutPipelineRequest in project OpenSearch by opensearch-project.
the class IngestClientIT method testPutPipeline.
public void testPutPipeline() throws IOException {
String id = "some_pipeline_id";
XContentBuilder pipelineBuilder = buildRandomXContentPipeline();
PutPipelineRequest request = new PutPipelineRequest(id, BytesReference.bytes(pipelineBuilder), pipelineBuilder.contentType());
AcknowledgedResponse putPipelineResponse = execute(request, highLevelClient().ingest()::putPipeline, highLevelClient().ingest()::putPipelineAsync);
assertTrue(putPipelineResponse.isAcknowledged());
}
use of org.opensearch.action.ingest.PutPipelineRequest in project OpenSearch by opensearch-project.
the class OpenSearchRestHighLevelClientTestCase method createPipeline.
protected static void createPipeline(String pipelineId) throws IOException {
XContentBuilder builder = buildRandomXContentPipeline();
createPipeline(new PutPipelineRequest(pipelineId, BytesReference.bytes(builder), builder.contentType()));
}
use of org.opensearch.action.ingest.PutPipelineRequest in project OpenSearch by opensearch-project.
the class OpenSearchRestHighLevelClientTestCase method createFieldAddingPipleine.
protected static void createFieldAddingPipleine(String id, String fieldName, String value) throws IOException {
XContentBuilder pipeline = jsonBuilder().startObject().startArray("processors").startObject().startObject("set").field("field", fieldName).field("value", value).endObject().endObject().endArray().endObject();
createPipeline(new PutPipelineRequest(id, BytesReference.bytes(pipeline), XContentType.JSON));
}
use of org.opensearch.action.ingest.PutPipelineRequest in project OpenSearch by opensearch-project.
the class GeoIpProcessorNonIngestNodeIT method testLazyLoading.
/**
* This test shows that we do not load the geo-IP databases on non-ingest nodes, and only load on ingest nodes on first use.
*
* @throws IOException if an I/O exception occurs building the JSON
*/
public void testLazyLoading() throws IOException {
assumeFalse("https://github.com/elastic/elasticsearch/issues/37342", Constants.WINDOWS);
final BytesReference bytes;
try (XContentBuilder builder = JsonXContent.contentBuilder()) {
builder.startObject();
{
builder.field("description", "test");
builder.startArray("processors");
{
builder.startObject();
{
builder.startObject("geoip");
{
builder.field("field", "ip");
builder.field("target_field", "ip-city");
builder.field("database_file", "GeoLite2-City.mmdb");
}
builder.endObject();
}
builder.endObject();
builder.startObject();
{
builder.startObject("geoip");
{
builder.field("field", "ip");
builder.field("target_field", "ip-country");
builder.field("database_file", "GeoLite2-Country.mmdb");
}
builder.endObject();
}
builder.endObject();
builder.startObject();
{
builder.startObject("geoip");
{
builder.field("field", "ip");
builder.field("target_field", "ip-asn");
builder.field("database_file", "GeoLite2-ASN.mmdb");
}
builder.endObject();
}
builder.endObject();
}
builder.endArray();
}
builder.endObject();
bytes = BytesReference.bytes(builder);
}
assertAcked(client().admin().cluster().putPipeline(new PutPipelineRequest("geoip", bytes, XContentType.JSON)).actionGet());
// the geo-IP databases should not be loaded on any nodes as they are all non-ingest nodes
Arrays.stream(internalCluster().getNodeNames()).forEach(node -> assertDatabaseLoadStatus(node, false));
// start an ingest node
final String ingestNode = internalCluster().startNode(NodeRoles.ingestNode());
internalCluster().getInstance(IngestService.class, ingestNode);
// the geo-IP database should not be loaded yet as we have no indexed any documents using a pipeline that has a geo-IP processor
assertDatabaseLoadStatus(ingestNode, false);
final IndexRequest indexRequest = new IndexRequest("index");
indexRequest.setPipeline("geoip");
indexRequest.source(Collections.singletonMap("ip", "1.1.1.1"));
final IndexResponse indexResponse = client().index(indexRequest).actionGet();
assertThat(indexResponse.status(), equalTo(RestStatus.CREATED));
// now the geo-IP database should be loaded on the ingest node
assertDatabaseLoadStatus(ingestNode, true);
// the geo-IP database should still not be loaded on the non-ingest nodes
Arrays.stream(internalCluster().getNodeNames()).filter(node -> node.equals(ingestNode) == false).forEach(node -> assertDatabaseLoadStatus(node, false));
}
use of org.opensearch.action.ingest.PutPipelineRequest in project OpenSearch by opensearch-project.
the class BulkIntegrationIT method createSamplePipeline.
private void createSamplePipeline(String pipelineId) throws IOException, ExecutionException, InterruptedException {
XContentBuilder pipeline = jsonBuilder().startObject().startArray("processors").startObject().startObject("test").endObject().endObject().endArray().endObject();
AcknowledgedResponse acknowledgedResponse = client().admin().cluster().putPipeline(new PutPipelineRequest(pipelineId, BytesReference.bytes(pipeline), XContentType.JSON)).get();
assertTrue(acknowledgedResponse.isAcknowledged());
}
Aggregations