Skip to content

Instantly share code, notes, and snippets.

@kireet
Created April 14, 2012 06:25
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 kireet/2382459 to your computer and use it in GitHub Desktop.
Save kireet/2382459 to your computer and use it in GitHub Desktop.
elastic search bug when running top_children queries
#!/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"}
}
}
}'`
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"
}'`
result=`curl -s -XPUT 'http://localhost:9200/tcbug/cm/c2?parent=p1' -d '
{
"cid" : "c1"
}'`
result=`curl -s -XPUT 'http://localhost:9200/tcbug/cm/c3?parent=p1' -d '
{
"cid" : "c1"
}'`
result=`curl -s -XPUT 'http://localhost:9200/tcbug/cm/c4?parent=p1' -d '
{
"cid" : "c1"
}'`
result=`curl -s -XPUT 'http://localhost:9200/tcbug/cm/c5?parent=p1' -d '
{
"cid" : "c1"
}'`
result=`curl -s -XPUT 'http://localhost:9200/tcbug/cm/c6?parent=p1' -d '
{
"cid" : "c1"
}'`
result=`curl -s -XPUT 'http://localhost:9200/tcbug/cm/c7?parent=p1' -d '
{
"cid" : "c1"
}'`
result=`curl -s -XPUT 'http://localhost:9200/tcbug/cm/c8?parent=p1' -d '
{
"cid" : "c1"
}'`
result=`curl -s -XPUT 'http://localhost:9200/tcbug/cm/c9?parent=p1' -d '
{
"cid" : "c1"
}'`
result=`curl -s -XPUT 'http://localhost:9200/tcbug/cm/c10?parent=p1' -d '
{
"cid" : "c1"
}'`
curl -s -XPOST 'http://localhost:9200/tcbug/_refresh'
#echo "direct query"
#result=`curl -s -XGET 'http://localhost:9200/tcbug/cm/_search?pretty=true' -d '
#{
# "query": {
# "term": {
# "cid": "c1"
# }
# }
#}'`
#echo "$result"
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" : {
"term" : {
"cid" : "c1"
}
},
"score" : "max",
"factor" : 3,
"incremental_factor" : 4
}
}}'`
echo "$result"
echo "children query"
result=`curl -s -XGET 'http://localhost:9200/tcbug/pm/_search?fields=*&pretty=true' -d '
{"size":1,
"query": {
"top_children" : {
"type": "cm",
"query" : {
"term" : {
"cid" : "c1"
}
},
"score" : "max",
"factor" : 10,
"incremental_factor" : 2
}
}}'`
echo "$result"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment