Created
November 26, 2013 16:35
-
-
Save jacquerie/7661529 to your computer and use it in GitHub Desktop.
When run gives:
{"ok":true,"_index":"_percolator","_type":"foo","_id":"barbaz1","_version":1}
{"ok":true,"_index":"_percolator","_type":"foo","_id":"barbaz2","_version":1}
{"ok":true,"matches":[]} Expecting:
{"ok":true,"_index":"_percolator","_type":"foo","_id":"barbaz1","_version":1}
{"ok":true,"_index":"_percolator","_type":"foo","_id":"barbaz…
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
#!/bin/bash | |
# Deletes, then creates the collection "foo". | |
curl -s -XDELETE localhost:9200/foo > /dev/null | |
curl -s -XPUT localhost:9200/foo > /dev/null | |
# Creates two percolators called "barbaz1" and "barbaz2" with different | |
# values in the "plugh" field. | |
curl -XPUT localhost:9200/_percolator/foo/barbaz1 -d '{ | |
"plugh": "xyzzy", | |
"query" : { | |
"term" : { | |
"bar" : "baz" | |
} | |
} | |
}' | |
echo "" | |
curl -XPUT localhost:9200/_percolator/foo/barbaz2 -d '{ | |
"plugh" : "waldo", | |
"query" : { | |
"term" : { | |
"bar" : "baz" | |
} | |
} | |
}' | |
echo "" | |
# First filters out all queries whose "plugh" field is not "waldo", then | |
# tries to match those. | |
curl -XGET localhost:9200/foo/qux/_percolate -d '{ | |
"doc": { | |
"bar": "baz" | |
}, | |
"query": { | |
"term": { | |
"plugh": "waldo" | |
} | |
} | |
}' | |
echo "" | |
# Deletes the created percolators. | |
curl -s -XDELETE localhost:9200/_percolator/foo/barbaz1 > /dev/null | |
curl -s -XDELETE localhost:9200/_percolator/foo/barbaz2 > /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment