Skip to content

Instantly share code, notes, and snippets.

@julianhille
Last active August 29, 2015 14:04
Show Gist options
  • Save julianhille/f4d1014a0072cc3233fb to your computer and use it in GitHub Desktop.
Save julianhille/f4d1014a0072cc3233fb to your computer and use it in GitHub Desktop.
ids filter in percolator
export ES_HOST=http://localhost:9200
export ES_INDEX=test
# delete & recreate index with defaults
curl -XDELETE $ES_HOST/$ES_INDEX -s -o /dev/null
curl -XPUT $ES_HOST/$ES_INDEX -s -o /dev/null
# configure the mapping of the bug type in the test index
curl -XPUT $ES_HOST/$ES_INDEX/bug/_mapping -s -o /dev/null -d '
{
"bug": {
"_id": {"path": "id"},
"properties": {
"id": {
"type": "integer",
"index": "not_analyzed",
"omit_norms": true
}
}
}
}
'
# Index a single percolator with terms filter on id
curl -X PUT $ES_HOST/$ES_INDEX/.percolator/terms_filter -d '
{
"query": {
"filtered": {
"filter": {
"terms":
{
"id": [1, 2, 3]
}
},
"query": {"match_all":{}}
}
},
"type":"bug"
}'
# Index a single percolator with ids filter
curl -X PUT $ES_HOST/$ES_INDEX/.percolator/ids_filter -d '
{
"query": {
"filtered": {
"filter": {
"ids": {
"values": [1,2,3]
}
},
"query": {
"match_all": {}
}
}
},
"type": "bug"
}'
curl -X PUT $ES_HOST/_refresh -s -o /dev/null
# percolate item
curl -XGET $ES_HOST/$ES_INDEX/bug/_percolate?pretty -d '
{
"doc": {
"id": "1"
}
}'
# percolate item
curl -XGET $ES_HOST/$ES_INDEX/bug/_percolate?pretty -d '
{
"doc": {
"_id": "1"
}
}'
# percolate item
curl -XGET $ES_HOST/$ES_INDEX/bug/_percolate?pretty -d '
{
"doc": {
"_uid": "bug#1"
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment