Skip to content

Instantly share code, notes, and snippets.

@julianhille
Last active August 29, 2015 14:02
Show Gist options
  • Save julianhille/bd23e8e43e28a193401e to your computer and use it in GitHub Desktop.
Save julianhille/bd23e8e43e28a193401e to your computer and use it in GitHub Desktop.
In this scriupt are two tests running each after another. For Es 1.2.1
export ES_HOST=http://localhost:9200
# delete & recreate index with defaults
curl -XDELETE $ES_HOST/test
curl -XPUT $ES_HOST/test
# configure the mapping of the bug type in the test index
curl -XPUT $ES_HOST/test/bug/_mapping -d'
{
"bug": {
"properties": {
"field": {
"type": "object",
"index": "not_analyzed",
"omit_norms": true
}
}
}
}
'
# Index a single percolator fro a not added dynamic field
curl -X PUT $ES_HOST/test/.percolator/1 -d '
{
"query": {
"filtered": {
"filter": {
"terms":
{
"field.1": [456]
}
},
"query": {"match_all":{}}
}
},
"type":"bug"
}'
# percolate a document which should hit.
curl -X GET $ES_HOST/test/bug/_percolate -d '
{
"doc" : {"field" : {"1": [123, 456, 789], "0": [123]}}
}'
# second tests
# delete & recreate index with defaults
curl -XDELETE $ES_HOST/test
curl -XPUT $ES_HOST/test
# configure the mapping of the bug type in the test index
curl -XPUT $ES_HOST/test/bug/_mapping -d'
{
"bug": {
"properties": {
"field": {
"type": "object",
"index": "not_analyzed",
"omit_norms": true
}
}
}
}
'
# Index a single document
curl -X PUT $ES_HOST/test/bug/1 -d '
{
"field" : {"1": [123, 456, 789], "0": [123]}
}'
# create a percolator
curl -X PUT $ES_HOST/test/.percolator/1 -d '
{
"query": {
"filtered": {
"filter": {
"terms":
{
"field.1": [456]
}
},
"query": {"match_all":{}}
}
},
"type":"bug"
}'
# percolate a document which should hit and does
curl -X GET $ES_HOST/test/bug/_percolate -d '
{
"doc" : {"field" : {"1": [123, 456, 789], "0": [123]}}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment