-
-
Save brusic/d3f9f82ec6c95c11585e to your computer and use it in GitHub Desktop.
SpanNotQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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