Search in sources :

Example 66 with IndexRequest

use of org.elasticsearch.action.index.IndexRequest in project samza by apache.

the class ElasticsearchSystemProducer method send.

@Override
public void send(String source, OutgoingMessageEnvelope envelope) {
    IndexRequest indexRequest = indexRequestFactory.getIndexRequest(envelope);
    sourceBulkProcessor.get(source).add(indexRequest);
}
Also used : IndexRequest(org.elasticsearch.action.index.IndexRequest)

Example 67 with IndexRequest

use of org.elasticsearch.action.index.IndexRequest in project samza by apache.

the class DefaultIndexRequestFactoryTest method testGetIndexRequestWithId.

@Test
public void testGetIndexRequestWithId() throws Exception {
    IndexRequest indexRequest = INDEX_REQUEST_FACTORY.getIndexRequest(new OutgoingMessageEnvelope(SYSTEM, "id", EMPTY_MSG));
    assertEquals("id", indexRequest.id());
}
Also used : IndexRequest(org.elasticsearch.action.index.IndexRequest) OutgoingMessageEnvelope(org.apache.samza.system.OutgoingMessageEnvelope) Test(org.junit.Test)

Example 68 with IndexRequest

use of org.elasticsearch.action.index.IndexRequest in project samza by apache.

the class DefaultIndexRequestFactoryTest method testGetIndexRequestNoPartitionKey.

@Test
public void testGetIndexRequestNoPartitionKey() throws Exception {
    IndexRequest indexRequest = INDEX_REQUEST_FACTORY.getIndexRequest(new OutgoingMessageEnvelope(SYSTEM, EMPTY_MSG));
    assertNull(indexRequest.routing());
}
Also used : IndexRequest(org.elasticsearch.action.index.IndexRequest) OutgoingMessageEnvelope(org.apache.samza.system.OutgoingMessageEnvelope) Test(org.junit.Test)

Example 69 with IndexRequest

use of org.elasticsearch.action.index.IndexRequest in project samza by apache.

the class DefaultIndexRequestFactoryTest method testGetIndexRequestStreamName.

@Test
public void testGetIndexRequestStreamName() {
    IndexRequest indexRequest = INDEX_REQUEST_FACTORY.getIndexRequest(new OutgoingMessageEnvelope(SYSTEM, EMPTY_MSG));
    assertEquals(INDEX, indexRequest.index());
    assertEquals(TYPE, indexRequest.type());
}
Also used : IndexRequest(org.elasticsearch.action.index.IndexRequest) OutgoingMessageEnvelope(org.apache.samza.system.OutgoingMessageEnvelope) Test(org.junit.Test)

Example 70 with IndexRequest

use of org.elasticsearch.action.index.IndexRequest in project samza by apache.

the class DefaultIndexRequestFactoryTest method testGetIndexRequestMessageMap.

@Test
public void testGetIndexRequestMessageMap() throws Exception {
    IndexRequest indexRequest = INDEX_REQUEST_FACTORY.getIndexRequest(new OutgoingMessageEnvelope(SYSTEM, Collections.singletonMap("foo", "bar")));
    assertEquals(Collections.singletonMap("foo", "bar"), indexRequest.sourceAsMap());
}
Also used : IndexRequest(org.elasticsearch.action.index.IndexRequest) OutgoingMessageEnvelope(org.apache.samza.system.OutgoingMessageEnvelope) Test(org.junit.Test)

Aggregations

IndexRequest (org.elasticsearch.action.index.IndexRequest)177 DeleteRequest (org.elasticsearch.action.delete.DeleteRequest)36 BulkRequest (org.elasticsearch.action.bulk.BulkRequest)34 UpdateRequest (org.elasticsearch.action.update.UpdateRequest)33 IOException (java.io.IOException)28 Test (org.junit.Test)27 DocWriteRequest (org.elasticsearch.action.DocWriteRequest)26 ElasticsearchException (org.elasticsearch.ElasticsearchException)20 IndexResponse (org.elasticsearch.action.index.IndexResponse)17 HashMap (java.util.HashMap)16 BulkResponse (org.elasticsearch.action.bulk.BulkResponse)15 Map (java.util.Map)14 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)14 DeleteIndexRequest (org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)13 GetRequest (org.elasticsearch.action.get.GetRequest)13 BytesReference (org.elasticsearch.common.bytes.BytesReference)12 ArrayList (java.util.ArrayList)10 Matchers.anyBoolean (org.mockito.Matchers.anyBoolean)9 BulkItemResponse (org.elasticsearch.action.bulk.BulkItemResponse)8 CreateIndexRequest (org.elasticsearch.client.indices.CreateIndexRequest)8