Skip to content

Instantly share code, notes, and snippets.

@brusic
Created August 21, 2012 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brusic/d3f9f82ec6c95c11585e to your computer and use it in GitHub Desktop.
Save brusic/d3f9f82ec6c95c11585e to your computer and use it in GitHub Desktop.
SpanNotQuery
# CREATE INDEX
curl -XPOST localhost:9200/test -d '{
"settings" : {
"number_of_replicas" : 0,
"number_of_shards" : 1
},
"mappings" : {
"type1" : {
"properties" : {
"field1" : { "type" : "string", "analyzer" : "whitespace" }
}
}
}
}'
# ADD SAMPLE DOCUMENTS
curl -XPUT http://localhost:9200/test/type1/1 -d '{
"field1" : "quick brown dog"
}'
curl -XPUT http://localhost:9200/test/type1/2 -d '{
"field1" : "quick brown fox"
}'
# QUERIES
# Should return both sample documents
curl -XGET 'http://localhost:9200/test/type1/_search?pretty=true' -d '
{
"query" : {
"span_term" : {
"field1" : "quick"
}
}
}
'
# should only return one document, but still returns both
curl -XGET 'http://localhost:9200/test/type1/_search?pretty=true' -d '
{
"query" : {
"span_not" : {
"include" : {
"span_term" : {
"field1" : "quick"
}
},
"exclude" : {
"span_term" : {
"field1" : "dog"
}
}
}
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment