Created
July 12, 2012 15:05
-
-
Save kireet/3098693 to your computer and use it in GitHub Desktop.
top children scoring bug
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 | |
echo "attempting index delete" | |
result=`curl -s -XDELETE 'http://localhost:9200/tcbug?pretty=true'` | |
echo "$result" | |
echo "attempting index creation" | |
result=`curl -s -XPOST 'http://localhost:9200/tcbug?pretty=true' -d '{ | |
"index": { | |
"number_of_shards": 1, | |
"number_of_replicas": 1, | |
"analysis": { | |
"analyzer": { | |
"default": { | |
"tokenizer": "standard", | |
"filter": ["standard", "lowercase", "asciifolding", "shingle", "stop"] | |
} | |
} | |
} | |
} | |
}'` | |
echo "$result" | |
echo "checking index status" | |
result=`curl -s -XGET 'http://localhost:9200/tcbug/_settings?pretty=true'` | |
echo "$result" | |
echo "creating parent mapping" | |
result=`curl -s -XPUT 'http://localhost:9200/tcbug/pm/_mapping?pretty=true' -d ' | |
{ | |
"pm": { | |
"_source" : {"enabled" : false}, | |
"properties": { | |
"pid": {"type": "string", "store": "yes", "index": "not_analyzed"} | |
} | |
} | |
}'` | |
echo $result | |
echo "creating child mapping" | |
result=`curl -s -XPUT 'http://localhost:9200/tcbug/cm/_mapping?pretty=true' -d ' | |
{ | |
"cm": { | |
"_parent": {"type": "pm"}, | |
"_source" : {"enabled" : false}, | |
"properties": { | |
"cid": {"type": "string", "store": "yes", "index": "not_analyzed"}, | |
"cval": {"type": "integer", "store": "yes", "index": "analyzed"} | |
} | |
} | |
}'` | |
echo "$result" | |
echo "creating parent" | |
result=`curl -s -XPUT 'http://localhost:9200/tcbug/pm/p1' -d ' | |
{ | |
"pid" : "p1" | |
}'` | |
echo "$result" | |
echo "creating child" | |
result=`curl -s -XPUT 'http://localhost:9200/tcbug/cm/c1?parent=p1' -d ' | |
{ | |
"cid" : "c1", | |
"cval": 1 | |
}'` | |
result=`curl -s -XPUT 'http://localhost:9200/tcbug/cm/c2?parent=p1' -d ' | |
{ | |
"cid" : "c1", | |
"cval": 1 | |
}'` | |
result=`curl -s -XPUT 'http://localhost:9200/tcbug/cm/c3?parent=p1' -d ' | |
{ | |
"cid" : "c1", | |
"cval": 1 | |
}'` | |
result=`curl -s -XPUT 'http://localhost:9200/tcbug/cm/c4?parent=p1' -d ' | |
{ | |
"cid" : "c1", | |
"cval": 1 | |
}'` | |
result=`curl -s -XPUT 'http://localhost:9200/tcbug/cm/c5?parent=p1' -d ' | |
{ | |
"cid" : "c1", | |
"cval": 1 | |
}'` | |
result=`curl -s -XPUT 'http://localhost:9200/tcbug/cm/c6?parent=p1' -d ' | |
{ | |
"cid" : "c1", | |
"cval": 1 | |
}'` | |
result=`curl -s -XPUT 'http://localhost:9200/tcbug/cm/c7?parent=p1' -d ' | |
{ | |
"cid" : "c1", | |
"cval": 1 | |
}'` | |
result=`curl -s -XPUT 'http://localhost:9200/tcbug/cm/c8?parent=p1' -d ' | |
{ | |
"cid" : "c1", | |
"cval": 1 | |
}'` | |
result=`curl -s -XPUT 'http://localhost:9200/tcbug/cm/c9?parent=p1' -d ' | |
{ | |
"cid" : "c1", | |
"cval": 1 | |
}'` | |
result=`curl -s -XPUT 'http://localhost:9200/tcbug/cm/c10?parent=p1' -d ' | |
{ | |
"cid" : "c1", | |
"cval": 1 | |
}'` | |
curl -s -XPOST 'http://localhost:9200/tcbug/_refresh' | |
echo "children query" | |
result=`curl -s -XGET 'http://localhost:9200/tcbug/pm/_search?fields=*&pretty=true' -d ' | |
{"size":2, | |
"query": { | |
"top_children" : { | |
"type": "cm", | |
"query" : { | |
"custom_score" : { | |
"query": { | |
"term" : { | |
"cid": "c1" | |
} | |
}, | |
"script" : "doc['"'"'cval'"'"'].value" | |
} | |
} | |
} | |
}}'` | |
echo "$result" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment