Package org.elasticsearch.client

Examples of org.elasticsearch.client.Client


            final ScriptInfo scriptInfo = getScriptValue(params);
            if (scriptInfo == null) {
                propertyValue = isArray ? strList : StringUtils.join(strList,
                        " ");
            } else {
                final Client client = riverConfig.getClient();
                final Map<String, Object> vars = new HashMap<String, Object>();
                vars.put("container",
                        SingletonS2ContainerFactory.getContainer());
                vars.put("client", client);
                vars.put("data", responseData);
View Full Code Here


            final Map<String, Object> dataMap) {
        final String sessionId = responseData.getSessionId();
        final String indexName = riverConfig.getIndexName(sessionId);
        final String typeName = riverConfig.getTypeName(sessionId);
        final boolean overwrite = riverConfig.isOverwrite(sessionId);
        final Client client = riverConfig.getClient();

        if (logger.isDebugEnabled()) {
            logger.debug("Index: " + indexName + ", sessionId: " + sessionId
                    + ", Data: " + dataMap);
        }

        if (overwrite) {
            client.prepareDeleteByQuery(indexName)
                    .setQuery(
                            QueryBuilders.termQuery("url",
                                    responseData.getUrl())).execute()
                    .actionGet();
            client.admin().indices().prepareRefresh(indexName).execute()
                    .actionGet();
        }

        @SuppressWarnings("unchecked")
        final Map<String, Object> arrayDataMap = (Map<String, Object>) dataMap
View Full Code Here

                return null;
            }
            if (logger.isDebugEnabled()) {
                logger.debug("Queued URL: {}", urlQueueList);
            }
            final Client client = riverConfig.getClient();
            for (final EsUrlQueue urlQueue : urlQueueList) {
                final String url = urlQueue.getUrl();
                if (exists(sessionId, url)) {
                    crawlingUrlQueue.add(urlQueue);
                    if (crawlingUrlQueue.size() > maxCrawlingQueueSize) {
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

        Logger.getLogger("test").info("querying " + searchHost + ":" + searchPort
                + " at " + searchIndexName + " with " + basicAuthCredentials);

        Settings settings = ImmutableSettings.settingsBuilder()
                .put("cluster.name", cluster).build();
        Client client = new TransportClient(settings).
                addTransportAddress(new InetSocketTransportAddress(searchHost, searchPort));

        Settings emptySettings = ImmutableSettings.settingsBuilder().build();
        RestController contrl = new RestController(emptySettings);
        ReIndexAction action = new ReIndexAction(emptySettings, client, contrl) {
            @Override protected MySearchHits callback(MySearchHits hits) {
                SimpleList res = new SimpleList(hitsPerPage, hits.totalHits());
                for (MySearchHit h : hits.getHits()) {
                    try {
                        String str = new String(h.source(), charset);
                        RewriteSearchHit newHit = new RewriteSearchHit(h.id(), h.parent(), h.version(), str);
                        String someField = newHit.get("some_field");
                        if (someField.contains("some content")) {
                            newHit.put("some_field", "IT WORKS!");
                        }

                        res.add(newHit);
                    } catch (UnsupportedEncodingException ex) {
                        throw new RuntimeException(ex);
                    }
                }
                return res;
            }
        };
        // first query, further scroll-queries in reindex!
        SearchRequestBuilder srb = action.createScrollSearch(searchIndexName, searchType, filter,
                hitsPerPage, withVersion, keepTimeInMinutes);
        SearchResponse sr = srb.execute().actionGet();
        MySearchResponse rsp = new MySearchResponseES(client, sr, keepTimeInMinutes);

        // now feed and call callback
        action.reindex(rsp, newIndexName, newType, withVersion, waitInSeconds);

        client.close();
    }
View Full Code Here

  }

  @Override
  @SuppressWarnings("unchecked")
  public <T extends ActionResponse> T executeGet(final NodeCallback<T> callback) {
    final Client client = node.client();
    final IndicesAdminClient indicesAdmin = client.admin().indices();
    final ActionFuture<?> action = callback.execute(indicesAdmin);
    final T response = (T) action.actionGet();
    client.close();
    return response;
  }
View Full Code Here

  }

  @Override
  @SuppressWarnings("unchecked")
  public <T extends ActionResponse> T executeGet(final ClusterCallback<T> callback) {
    final Client client = node.client();
    final ClusterAdminClient clusterAdmin = client.admin().cluster();
    final ActionFuture<?> action = callback.execute(clusterAdmin);
    final T response = (T) action.actionGet();
    client.close();
    return response;
  }
View Full Code Here

    return response;
  }

  @Override
  public <T extends ActionResponse> T executeGet(final ClientCallback<T> callback) {
    final Client client = node.client();
    final ActionFuture<T> action = callback.execute(client);
    final T response = action.actionGet();
    client.close();
    return response;
  }
View Full Code Here

                .put("name", id)
                .put("gateway.type", "none")
                .put("cluster.routing.schedule", "50ms")
                .build();
        Node node = nodeBuilder().settings(finalSettings).build();
        Client client = node.client();
        nodes.put(id, node);
        clients.put(id, client);
        return node;
    }
View Full Code Here

    sPort = hostPort[1];

    Builder globalSettings = ImmutableSettings.settingsBuilder();
    Settings snode = globalSettings.put("cluster.name", _clusterName).build();
   
    Client client = null;
    TransportClient tmp = null;
    try {
      tmp = new TransportClient(snode);
      client = tmp.addTransportAddress(new InetSocketTransportAddress(sHostname, Integer.parseInt(sPort)));
   
      if (!IndexExistsUtils.exists(client.admin().indices(), indexName)) {
        return false;
      }
      client.admin().cluster().health(new ClusterHealthRequest(indexName).waitForYellowStatus()).actionGet();
    }
    catch (Exception e) { // Index not alive...
      return false;
    }
    finally {
      if (null != client) {
        client.close(); // (will also close tmp)
      }
      else if (null != tmp) {
        tmp.close();
      }
    }
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.