-
-
Save m-brown/59b9b5ad6f68a5d12d0a to your computer and use it in GitHub Desktop.
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
# setup | |
curl -XDELETE 'http://localhost:9200/test' | |
curl -XPUT 'http://localhost:9200/test/' | |
curl -XPUT 'http://localhost:9200/test/document/_mapping' -d ' | |
{ | |
"document" : { | |
"dynamic": "strict", | |
"properties" : { | |
"field1" : {"type" : "string", "store" : true } | |
} | |
} | |
} | |
' | |
# test data | |
curl -XPOST 'http://localhost:9200/test/document/' -d '{"field1": "foo"}' | |
curl -XPOST 'http://localhost:9200/test/document/' -d '{"field1": "foo bar"}' | |
curl -XPOST 'http://localhost:9200/test/document/' -d '{"field1": "bar foo"}' | |
curl -XPOST 'http://localhost:9200/test/document/' -d '{"field1": "foo foo bar"}' | |
curl -XPOST 'http://localhost:9200/test/document/' -d '{"field1": "foo bar foo"}' | |
curl -XPOST 'http://localhost:9200/test/document/' -d '{"field1": "bar foo foo"}' | |
# Query to find docs with foo but not bar. | |
# Should return 1 doc but returns 'foo' and 'bar foo foo' | |
curl 'http://localhost:9200/test/_search?pretty=true' -d ' | |
{ | |
"query": { | |
"span_not": { | |
"include": { | |
"span_term": { | |
"field1": "foo" | |
} | |
}, | |
"exclude": { | |
"span_near": { | |
"in_order": false, | |
"clauses": [ | |
{ | |
"span_term": { | |
"field1": "bar" | |
} | |
}, | |
{ | |
"span_term": { | |
"field1": "foo" | |
} | |
} | |
], | |
"slop": 1000 | |
} | |
} | |
} | |
} | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment