Skip to content

Instantly share code, notes, and snippets.

@julesbravo
Created March 4, 2014 23:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julesbravo/9357887 to your computer and use it in GitHub Desktop.
Save julesbravo/9357887 to your computer and use it in GitHub Desktop.
Broken Percolator with Range Filters
#!/bin/bash
echo "Deleting Old Index: "
curl -XDELETE "http://localhost:9200/merchandising"
echo "
";
echo "Creating Index: "
curl -XPUT "http://localhost:9200/merchandising" -d '{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0
}
}
}'
echo "
";
echo "Create Percolator Mapping: "
curl -XPUT "http://localhost:9200/merchandising/.percolator/_mapping" -d '{
".percolator" : {
"properties" : {
"type" : {
"type" : "string",
"index" : "not_analyzed"
},
"query" : {
"type" : "object",
"enabled" : false
}
}
}
}'
echo "
";
echo "Create Query Mapping: "
curl -XPUT "http://localhost:9200/merchandising/trigger/_mapping" -d '{
"trigger" : {
"properties" : {
"ts" : {
"type" : "integer"
}
}
}
}'
echo "
";
echo "Add Percolator: "
curl -XPUT "http://localhost:9200/merchandising/.percolator/8" -d'{
"query": {
"filtered": {
"query": {
"match_all" : {}
},
"filter": {
"range": {
"ts": {
"lte": 100
}
}
}
}
},
"type": "1"
}'
echo "
";
sleep 2;
echo "Percolate (Should Return Result): "
curl -XPOST "http://localhost:9200/merchandising/trigger/_percolate" -d '{
"doc" : {
"ts": 10
}
}'
echo "
";
echo "Percolate (Should Return No Results): "
curl -XPOST "http://localhost:9200/merchandising/trigger/_percolate" -d '{
"doc" : {
"ts": 1000
}
}'
echo "
";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment