Skip to content

Instantly share code, notes, and snippets.

# Have an index created with "no_stopwords" analyzer
curl -XPUT 'http://localhost:9200/my_twitter1/' -d '
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0,
"analysis" : {
"analyzer" : {
"no_stopwords" : {
##################### ElasticSearch Configuration Example #####################
# This file contains an overview of various configuration settings.
#
# ElasticSearch comes with reasonable defaults for most settings,
# so you can try it out without bothering with configuration.
#
# Most of the time, these defaults are just fine for running a production
# cluster. If you're fine-tuning your cluster, or wondering about the
# effect of certain configuration option, please _do ask_ on the
curl -XPUT 'http://localhost:9200/test/' -d '{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0,
"analysis": {
"analyzer": {
"containsText" : {
"tokenizer": "whitespace",
"filter": ["asciifolding", "lowercase", "autocomplete"]
curl -XPUT localhost:9200/test -d '{
"mappings" : {
"type1" : {
"properties" : {
"name" : {
"type" : "multi_field",
"fields" : {
"name" : {"type" : "string", "index" : "analyzed"},
"untouched" : {"type" : "string", "index" : "not_analyzed"}
}
# Start two nodes (run bin/elasticsearch -f twice) and run:
curl -XPOST localhost:9200/test -d '{
"settings" : {
"number_of_shards" : 3
}
}'
# Run cluster state, under routing_nodes element, you will see the shards allocated on each node
curl localhost:9200/_cluster/state?pretty=1
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"} },
curl -XPUT localhost:9200/test/type1/1 -d '{
"field1" : 10,
"field2" : 20
}'
curl -XPUT localhost:9200/test/type1/2 -d '{
"field1" : 7,
"field2" : 3
}'
cloud:
aws:
access_key: XXX
secret_key: XXX
region: us-east-1
network:
host: _ec2:privateIpv4_
discovery:
curl -XGET 'http://localhost:9200/disqus/thread/_search' -d $'{
"fields": [],
"query": {
"custom_score": {
"query": {
"filtered" : {
"query" : {
"more_like_this": {
"fields": ["content"],
"like_text": "Eptaff"
curl -XPUT 'http://localhost:9200/_percolator/sp6/mehtryx' -d '{"request":{"id":139051389555982340,"from":"PythiaTest","sent":"Tue, 22 Nov 2011 18:43:29 +0000","message":"@AskPythia Toronto Maple Leafs"},"query":{"bool":{"must":[{"query_string":{"query":"Toronto Maple Leafs","default_operator":"AND"}},{"term":{"type":"STRY"}}]}}}'