Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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