Package org.elasticsearch.client

Examples of org.elasticsearch.client.Client


        installSearchModule();
    }

    public void installSearchModule() {
        try {
            Client client = AbstractElasticSearch.createClient(ElasticNode.CLUSTER,
                    "127.0.0.1", ElasticNode.PORT);

            MySearch tweetSearch = new MySearch(client);
            tweetSearch.nodeInfo();
            bind(MySearch.class).toInstance(tweetSearch);
View Full Code Here


            bind(GenericUrlResolver.class).toInstance(urlResolver);       
    }

    public void installSearchModule() {
        // TODO shouldn't fail when node is not available!!??
        Client client = AbstractElasticSearch.createClient(ElasticNode.CLUSTER,
                config.getTweetSearchUrl(), ElasticNode.PORT);

        ElasticTweetSearch tweetSearch = new ElasticTweetSearch(client);
        try {
            tweetSearch.nodeInfo();
View Full Code Here

     * Test if an indice Exists
     * @return true if exists
     */
    public static boolean existsIndex(String indexName) {

        Client client = IndexClient.client;
        AdminClient admin = client.admin();
        IndicesAdminClient indices = admin.indices();
        IndicesExistsRequestBuilder indicesExistsRequestBuilder = indices.prepareExists(indexName);
        IndicesExistsResponse response = indicesExistsRequestBuilder.execute().actionGet();

        return response.isExists();
View Full Code Here

    @Bean
    public Client elasticSearchClient() throws Exception {
        NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder().local(true);
        nodeBuilder.getSettings().put("network.host", "127.0.0.1");
        node = nodeBuilder.node();
        Client client = node.client();
        return client;
    }
View Full Code Here

        if (operation == null) {
            throw new IllegalArgumentException(ElasticsearchConfiguration.PARAM_OPERATION + " is missing");
        }

        Client client = getEndpoint().getClient();

        if (operation.equalsIgnoreCase(ElasticsearchConfiguration.OPERATION_INDEX)) {
            addToIndex(client, exchange);
        } else if (operation.equalsIgnoreCase(ElasticsearchConfiguration.OPERATION_GET_BY_ID)) {
            getById(client, exchange);
View Full Code Here

            public void run() {
                nodeBuilder().client(true).node().close();
            }
        });

        final Client client = new TransportClient()
                .addTransportAddress(new InetSocketTransportAddress(
                        config.getString("restopengov.elasticsearch-host"),
                        config.getInt("restopengov.elasticsearch-port")));

View Full Code Here

  @Override
  public void invoke(ElasticSearchIndexEvent message) {
    // Log Debug
    Logger.info("Elastic Search - %s Event", message);

    Client client = ElasticSearchPlugin.client();
    Model object = message.getObject();
    @SuppressWarnings("unchecked")
    ModelMapper<Model> mapper = (ModelMapper<Model>) ElasticSearchPlugin.getMapper(object.getClass());

    // Index Event
View Full Code Here

    clients.put(id, node.client());
    return node;
  }

  public void closeNode(String id) {
    Client client = clients.remove(id);
    if (client != null) {
      client.close();
    }
    Node node = nodes.remove(id);
    if (node != null) {
      node.close();
    }
View Full Code Here

    }

    final Server esServer = new Server(args.getCluster(), args.getDataDirectory());
    esServer.start();

    Client esNodeClient = esServer.getClient();

    if(args.isDeleteIndex()) {
      esServer.recreateIndex();
      log.info("deleted photon index and created an empty new one.");
      return;
View Full Code Here

  }

  public void recreateIndex() {
    deleteIndex();

    final Client client = this.getClient();
    final InputStream mappings = Thread.currentThread().getContextClassLoader().getResourceAsStream("mappings.json");
    final InputStream index_settings = Thread.currentThread().getContextClassLoader().getResourceAsStream("index_settings.json");

    try {
      client.admin().indices().prepareCreate("photon").setSettings(IOUtils.toString(index_settings)).execute().actionGet();
      client.admin().indices().preparePutMapping("photon").setType("place").setSource(IOUtils.toString(mappings)).execute().actionGet();
    } catch(IOException e) {
      log.error("cannot setup index, elastic search config files not readable", e);
    }
  }
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.