env('ELASTICSEARCH_HOST', 'http://localhost:9200'),
Не?leah@xxx:~$ curl -XGET http://localhost:9200
{
"name" : "DR4r-FT",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "Q4TCatpdSkaMoqlezR-TQQ",
"version" : {
"number" : "5.1.1",
"build_hash" : "5395e21",
"build_date" : "2016-12-06T12:36:15.409Z",
"build_snapshot" : false,
"lucene_version" : "6.3.0"
},
"tagline" : "You Know, for Search"
}
leah@xxxx:~$
sudo bin/elasticsearch-plugin install ingest-attachment
MacBook-Pro:elasticsearch-5.1.1 leah$ ./bin/elasticsearch-plugin install ingest-attachment
-> Downloading ingest-attachment from elastic
[=================================================] 100%
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: plugin requires additional permissions @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
* java.lang.RuntimePermission getClassLoader
* java.lang.reflect.ReflectPermission suppressAccessChecks
* java.security.SecurityPermission createAccessControlContext
* java.security.SecurityPermission insertProvider
* java.security.SecurityPermission putProviderProperty.BC
See http://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
for descriptions of what these permissions allow and the associated risks.
Continue with installation? [y/N]y
-> Installed ingest-attachment
MacBook-Pro:elasticsearch-5.1.1 leah$
String query = "{\n" +
" \"query\": { \"match_all\": {}\n" +
" }" +
"}\n" +
"\n" +
"";
Response response = client.performRequest("GET","/offers_v1/offer/_search", new Hashtable<>(),
new StringEntity(query));
HttpEntity entity = response.getEntity();
ObjectMapper ob = new ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
ResponseHits responseHits = ob.readValue(entity.getContent(), ResponseHits.class);
List<Hit> hits = responseHits.getHits().getHits();
return Results.html("index").put("hits", hits);
public class ResponseHits {
private Hits hits;
}
public class Hits {
private List<Hit> hits;
}
public class Hit {
@JsonProperty(value = "_index")
private String index;
@JsonProperty(value = "_type")
private String type;
@JsonProperty(value = "_id")
private String id;
@JsonProperty(value = "_score")
private Double score;
@JsonProperty(value = "_source")
private Hashtable<String, Object> source;
}
from elasticsearch import Elasticsearch, helpers
es = Elasticsearch()
def mybulk_delete(q, index, doc_type):
res = helpers.scan(es,
query={"query": q},
index=index, doc_type= doc_type)
for r in res:
yield {"delete" : { "_index" : r["_index"], "_type" : r["_type"], "_id" : r["_id"] } }
q = {"query":{"term":{"user":"kimchy"}}}
k = (i for i in mybulk_delete(q,"myindex", "mytype"))
helpers.bulk(es, k, refresh = True)