public void close() { if (connection != null) { connection.close(); } } }
public static ElasticConnection getConnection(String hostname, int transportPort) { return getConnection(hostname, transportPort, DEFAULT_FLUSH_INTERVAL_STRING, DEFAULT_BULK_LISTENER); }
public static EsNamedQueryOperations getInstance(ElasticConnection connection, String index, String type) { return new EsNamedQueryOperations(connection, index, type); }
public void delete(String url) { if (url != null) { getConnection().getClient().prepareDelete(getIndex(), getType(), url.toLowerCase()).get(); } }
public void delete(String url) { if (url != null) { getConnection().getClient().prepareDelete(getIndex(), getType(), url.toLowerCase()).get(); } }
public void delete(NamedQuery nq) { if (nq != null && nq.getName() != null) { getConnection().getClient().prepareDelete(getIndex(), getType(), nq.getName()).get(); } }
public HttpSource load(String url) { return operations.get(url); } });
public static EsHttpSourceTestOperations getInstance(ElasticConnection connection, String index, String type) { return new EsHttpSourceTestOperations(connection, index, type); }
public static EsHttpSourceOperations getInstance(ElasticConnection connection, String index, String type) { return new EsHttpSourceOperations(connection, index, type); }
public static EsDocumentOperations getInstance(ElasticConnection connection, String indexName, String type) { return new EsDocumentOperations(connection, indexName, type); }
public static EsHttpUrlOperations getInstance(ElasticConnection connection, String index, String type) { return new EsHttpUrlOperations(connection, index, type); }
public void store(HttpArticle article) throws IOException { store(article, Collections.emptyMap()); }
private void applyField(XContentBuilder builder, String fieldName, Map<String, Object> fieldValues, Object defaultValue) throws IOException { Object fieldValue = fieldValues.getOrDefault(fieldName, defaultValue); if (fieldValue != null) { builder.field(fieldName, Utils.formatFieldValue(fieldValue)); } }
public static EsHttpSourceOperations getHttpSourceOperations() { if (HTTP_SOURCE_OPERATIONS == null) { String index = Configuration.INSTANCE.getString(ElasticConstants.ES_HTTP_SOURCES_INDEX_NAME_PARAM); String type = Configuration.INSTANCE.getString(ElasticConstants.ES_HTTP_SOURCES_DOC_TYPE_PARAM); HTTP_SOURCE_OPERATIONS = EsHttpSourceOperations.getInstance(getEsConnection(), index, type); } return HTTP_SOURCE_OPERATIONS; }
public static EsNamedQueryOperations getNamedQueryOperations() { if (NAMED_QUERY_OPERATIONS == null) { String index = Configuration.INSTANCE.getString(ElasticConstants.ES_NAMED_QUERIES_INDEX_PARAM); String type = Configuration.INSTANCE.getString(ElasticConstants.ES_NAMED_QUERIES_TYPE_PARAM); NAMED_QUERY_OPERATIONS = EsNamedQueryOperations.getInstance(getEsConnection(), index, type); } return NAMED_QUERY_OPERATIONS; }
public HttpSourceTest get(String url) { GetResponse response = getConnection().getClient().prepareGet(getIndex(), getType(), url) .setFetchSource(true) .get(); if (response.isExists()) { return mapToHttpSourceTest(response.getSource()); } return null; }
public HttpSource get(String url) { GetResponse response = getConnection().getClient().prepareGet(getIndex(), getType(), url) .setFetchSource(true) .get(); if (response.isExists()) { return mapToHttpSource(response.getSource()); } return null; }
public NamedQuery get(String name) { GetResponse response = getConnection().getClient() .prepareGet(getIndex(), getType(), name.toLowerCase()) .setFetchSource(true) .get(); if (response.isExists()) { return mapToNamedQuery(response.getSource()); } return null; }
public static ElasticConnection getConnection(String hostname) { return getConnection(hostname, DEFAULT_TRANSPORT_PORT, DEFAULT_FLUSH_INTERVAL_STRING, DEFAULT_BULK_LISTENER); }
private static ElasticConnection getEsConnection() { if (CONNECTION == null) { String hostname = Configuration.INSTANCE.getString(ElasticConstants.ES_HOSTNAME_PARAM, "localhost"); int transportPort = Configuration.INSTANCE.getInt(ElasticConstants.ES_TRANSPORT_PORT_PARAM, 9300); CONNECTION = ElasticConnection.getConnection(hostname, transportPort); } return CONNECTION; } }