Package org.elasticsearch.client

Examples of org.elasticsearch.client.Client


    private static final String TOPIC_NAME = "tpolq_kafka";

    private final RateLimiter rateLimiter = RateLimiter.create(20); // setting 10 per second

    private Client createMockedESClient() {
        Client client = mock(Client.class);

        doAnswer(new Answer() {
            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable {
                final BulkRequest req = (BulkRequest) invocation.getArguments()[0];
View Full Code Here


        final ObjectMapper jsonMapper = new DefaultObjectMapper();

        final KafkaSink kafkaSink = createKafkaProducer(jsonMapper, kafkaServer.getBrokerListStr());

        Client client = createMockedESClient();

        final ElasticSearchSink sink = new ElasticSearchSink(
                null,
                10,
                1000,
View Full Code Here

    private static final Client INSTANCE = getInstance();

    public static Client getInstance() {
            Node node = nodeBuilder().node();
            Client client = node.client();
            createIndex(INSTANCE);
            return client;
    }
View Full Code Here

        /**
         * Here, we're using a singleton because we're connecting to a local in-memory ES-cluster.
         * In a real world application, you should just instantiate a client to connect
         * to your production database.
         */
        Client client = ElasticSearchSingleton.getInstance();
        return new ElasticSearchState(client);
    }
View Full Code Here

    @BenchmarkOptions(benchmarkRounds = BENCHMARK_ROUNDS, warmupRounds = 1)
    @Test
    public void testESBulkDelete() {
        HashMap<String, String> ids = createSampleData();
        Client client = getClient(false);
        BulkRequestBuilder request = new BulkRequestBuilder(client);

        for(String id: ids.values()){
            DeleteRequest deleteRequest = new DeleteRequest("users", "default", id);
            request.add(deleteRequest);
View Full Code Here

                executor.submit(new Runnable() {
                    @Override
                    public void run() {
                        int numDocsToCreate = NUMBER_OF_DOCUMENTS/4;
                        logger.info("Generating {} Documents in Thread {}", numDocsToCreate, Thread.currentThread().getName());
                        Client client = getClient(false);
                        BulkRequest bulkRequest = new BulkRequest();

                        for (int i=0; i < numDocsToCreate; i+=1000) {
                            bulkRequest.requests().clear();
                            try {
                                byte[] source = generateRowSource();
                                for (int j=0; j<1000;j++) {
                                    IndexRequest indexRequest = new IndexRequest(INDEX_NAME, "default", String.valueOf(i+j) + String.valueOf(Thread.currentThread().getId()));
                                    indexRequest.source(source);
                                    bulkRequest.add(indexRequest);
                                }
                                BulkResponse response = client.bulk(bulkRequest).actionGet();
                                assertFalse(response.hasFailures());
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                        }
View Full Code Here

    @Test
    public void testInsertAtNodeWithoutShard() throws Exception {
        setUpSimple(1);

        Iterator<Client> iterator = clients().iterator();
        Client client1 = iterator.next();
        Client client2 = iterator.next();

        client1.execute(SQLAction.INSTANCE, new SQLRequest(
            "insert into t1 (id, string_field, " +
                "timestamp_field, byte_field) values (?, ?, ?, ?)", new Object[]{1, "With",
            "1970-01-01T00:00:00", 127})).actionGet();

        client2.execute(SQLAction.INSTANCE, new SQLRequest(
            "insert into t1 (id, string_field, timestamp_field, byte_field) values (?, ?, ?, ?)",
            new Object[]{2, "Without", "1970-01-01T01:00:00", Byte.MIN_VALUE})).actionGet();
        refresh();
        SQLResponse response = execute("select id, string_field, timestamp_field, byte_field from t1 order by id");
View Full Code Here

        return xmlBeans;
    }

  @Test
  public void test_custom_analyzer() {
        Client client = checkClient("esClient");

        GetSettingsResponse response = client.admin().indices().prepareGetSettings().get();
        assertThat(response.getSetting("twitter", "index.analysis.analyzer.francais.type"), is("custom"));
    }
View Full Code Here

        return xmlBeans;
    }

  @Test
  public void test_template() {
    Client client = checkClient();

        GetIndexTemplatesResponse response = client.admin().indices().prepareGetTemplates().get();
        assertThat(response.getIndexTemplates().size(), is(1));
    }
View Full Code Here

        return xmlBeans;
    }

  @Test
  public void test_transport_client() {
    Client client = checkClient("esClient");
        assertThat("tweet type should exist in twitter index", isMappingExist(client, "twitter", "tweet"), is(true));
  }
View Full Code Here

TOP

Related Classes of org.elasticsearch.client.Client

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.