Skip to content

Instantly share code, notes, and snippets.

@imotov
Created July 12, 2013 12:33
Show Gist options
  • Save imotov/5984118 to your computer and use it in GitHub Desktop.
Save imotov/5984118 to your computer and use it in GitHub Desktop.
curl -XDELETE localhost:9200/test-idx
curl -XPUT localhost:9200/test-idx -d '{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0,
"analysis": {
"analyzer": {
"region_analyzer": {
"tokenizer": "my_ngram"
}
},
"tokenizer": {
"my_ngram": {
"type": "edgeNGram",
"min_gram": 1,
"max_gram": 100
}
}
}
}
},
"mappings": {
"doc": {
"properties": {
"region": {"type": "string", "index_analyzer": "region_analyzer", "search_analyzer": "keyword"}
}
}
}
}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0006001U000E"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0006001U0009"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0006001U000Z"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0002001U000Q"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0002001U000E"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0002001U000D"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0002001U0009"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0003001U000G"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0003001U000E"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0003001U0009"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0003001U000K"}'
curl -XPOST localhost:9200/test-idx/_refresh
echo
curl "localhost:9200/test-idx/doc/_search?pretty=true" -d '{
"query": {
"match": {
"region": "001D000600"
}
},
"fields": ["region"]
}'
echo
curl "localhost:9200/test-idx/doc/_search?pretty=true" -d '{
"query": {
"match": {
"region": "001D0006001U000E"
}
},
"fields": ["region"]
}'
curl -XDELETE localhost:9200/test-idx
curl -XPUT localhost:9200/test-idx -d '{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0
}
},
"mappings": {
"doc": {
"properties": {
"region": {"type": "string", "index": "not_analyzed"}
}
}
}
}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0006001U000E"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0006001U0009"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0006001U000Z"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0002001U000Q"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0002001U000E"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0002001U000D"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0002001U0009"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0003001U000G"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0003001U000E"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0003001U0009"}'
curl -XPOST localhost:9200/test-idx/doc -d '{"region": "001D0003001U000K"}'
curl -XPOST localhost:9200/test-idx/_refresh
echo
curl "localhost:9200/test-idx/doc/_search?pretty=true" -d '{
"query": {
"wildcard": {
"region": "001D000600*"
}
},
"fields": ["region"]
}'
echo
curl "localhost:9200/test-idx/doc/_search?pretty=true" -d '{
"query": {
"wildcard": {
"region": "001D0006001U000E*"
}
},
"fields": ["region"]
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment