Skip to content

Instantly share code, notes, and snippets.

curl localhost:9200/_search -d '{
"query" : {
"filtered" : {
"query" : {"match_all" : {}},
"filter" : {
"and" : [
{
"range" : {
"file_size" : {"from" : 10, "to" : 10000}
}
curl -XPUT localhost:9200/test
curl -XPUT http://localhost:9200/test/data/_mapping -d '{
"data" : {
"dynamic_templates" : [
{
"string_template" : {
"match" : "*",
"match_mapping_type" : "string",
"mapping" : {
curl -XPUT localhost:9200/test
curl -XPUT localhost:9200/test/tweet/_mapping -d '
{
"tweet" : {
"properties" : {
"name" : {
"type" : "string"
},
"comments" : {
"properties" : {
curl -XPOST 'http://localhost:9200/twitter/_optimize?max_num_segments=2'
curl -XPUT localhost:9200/test -d '
{"settings": {
"analysis" :{
"analyzer": {
"exact_analyzer": {
"type": "custom",
"tokenizer":"my_pattern_tokenizer",
"filter":[]
}
},
curl -XPUT 'http://localhost:9200/_template/template_logstash/' -d '
{
"template": "logstash-*",
"mappings": {
"_default_": { "_source": { "compress": "true" } }
}
}'
curl -XPUT http://localhost:9200/twitter/foo/1 -d '{"message": "hello world"}'
curl -XPUT http://localhost:9200/twitter/bar/1 -d '{"message": "hello world"}'
# Use bool query with should clause, which ends up aggregating the scores if matching
# several clauses
curl -XGET 'http://localhost:9200/twitter/_search?pretty=1' -d '{
"query" : {
"bool" : {
"should" : [
{ "text" : { "message" : "hello"} },
index:
analysis:
analyzer:
string_lowercase:
tokenizer: keyword
filter: lowercase
curl -XPUT localhost:9200/test/type1/1 -d '{
a : [
{ x:1, y:2 },
{ x:2, y:3 }
]
}'
curl -XPOST localhost:9200/test/_refresh
curl 'localhost:9200/test/_search?q=*&fields=a.x'
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import org.elasticsearch.search.facet.FacetBuilders;
import org.elasticsearch.search.facet.datehistogram.DateHistogramFacet;
import org.joda.time.DateTimeZone;
import org.joda.time.format.ISODateTimeFormat;