Skip to content

Instantly share code, notes, and snippets.

@bonzanini
Created February 8, 2015 17:57
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save bonzanini/e1a330b9e2c3e44c442c to your computer and use it in GitHub Desktop.
Save bonzanini/e1a330b9e2c3e44c442c to your computer and use it in GitHub Desktop.
Elasticsearch Proximity/Phrase Search
curl -XDELETE http://localhost:9200/test/articles
curl -XPUT http://localhost:9200/test/_mapping/articles -d '{
"properties": {
"content": {
"type": "string",
"position_offset_gap": 100
}
}
}'
curl -XPOST http://localhost:9200/test/articles/1 -d '{
"content": ["This is a brown fox", "This is white dog"]
}'
curl -XPOST http://localhost:9200/test/articles/2 -d '{
"content": ["This is a brown dog", "The dog is on the table"]
}'
curl -XPOST http://localhost:9200/test/articles/3 -d '{
"content": ["This dog is really brown", "I mean, really really brown"]
}'
curl -XPOST http://localhost:9200/test/articles/4 -d '{
"content": ["The dog is brown but this document is very very long"]
}'
curl -XPOST http://localhost:9200/test/articles/5 -d '{
"content": ["There is also a white cat", "How about a pink elephant?"]
}'
curl -XPOST http://localhost:9200/test/articles/6 -d '{
"content": ["The quick brown fox jumps over the lazy dog"]
}'
curl -XPOST http://localhost:9200/test/articles/1 -d '{
"content": "This is a brown fox"
}'
curl -XPOST http://localhost:9200/test/articles/2 -d '{
"content": "This is a brown dog"
}'
curl -XPOST http://localhost:9200/test/articles/3 -d '{
"content": "This dog is really brown"
}'
curl -XPOST http://localhost:9200/test/articles/4 -d '{
"content": "The dog is brown but this document is very very long"
}'
curl -XPOST http://localhost:9200/test/articles/5 -d '{
"content": "There is also a white cat"
}'
curl -XPOST http://localhost:9200/test/articles/6 -d '{
"content": "The quick brown fox jumps over the lazy dog"
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment