This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl localhost:9200/_search -d '{ | |
"query" : { | |
"filtered" : { | |
"query" : {"match_all" : {}}, | |
"filter" : { | |
"and" : [ | |
{ | |
"range" : { | |
"file_size" : {"from" : 10, "to" : 10000} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" : { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XPUT localhost:9200/test | |
curl -XPUT localhost:9200/test/tweet/_mapping -d ' | |
{ | |
"tweet" : { | |
"properties" : { | |
"name" : { | |
"type" : "string" | |
}, | |
"comments" : { | |
"properties" : { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XPOST 'http://localhost:9200/twitter/_optimize?max_num_segments=2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XPUT localhost:9200/test -d ' | |
{"settings": { | |
"analysis" :{ | |
"analyzer": { | |
"exact_analyzer": { | |
"type": "custom", | |
"tokenizer":"my_pattern_tokenizer", | |
"filter":[] | |
} | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XPUT 'http://localhost:9200/_template/template_logstash/' -d ' | |
{ | |
"template": "logstash-*", | |
"mappings": { | |
"_default_": { "_source": { "compress": "true" } } | |
} | |
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"} }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
index: | |
analysis: | |
analyzer: | |
string_lowercase: | |
tokenizer: keyword | |
filter: lowercase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
NewerOlder