Script not supporting nested if-else or switch case

Hi there,
I am trying to run the following query, its responding well
if I am using simple if-else in script, but my requirement is different for
different fields which requires nested or ladder if-else or switch case,
None of these if working with script tag. Can you please help me out, what
is the issue with the query?

{
"query": {
"custom_score": {
"query": {
"filtered": {
"query": {
"bool": {
"should": [
{
"text": {
"searchable.title": {
"type": "phrase_prefix",
"query": "k",
"analyzer": null
}
}
},
{
"text": {
"searchable.code": {
"type": "phrase_prefix",
"query": "k",
"analyzer": null
}
}
},
{
"text": {
"searchable.zip": {
"type": "phrase_prefix",
"query": "k"
}
}
}
]
}
},
"filter": {
"and": [
{
"term": {
"follower_of_inverse": "34"
}
},
{
"or": [
{
"prefix": {
"searchable.title": "k"
}
},
{
"prefix": {
"searchable.code": "k"
}
},
{
"prefix": {
"searchable.zip": "k"
}
}
]
}
]
}
}
},
"script": {
"script": "if(doc['subtype'].value=='abc') scorepow(10,3);
elseif(doc['subtype'].value=='def')_score
pow(10,0); else _score"
}
}
},
"size": 7
}

On Fri, 2011-10-28 at 03:51 -0700, Narinder Kaur wrote:

Hi there,
I am trying to run the following query, its responding
well if I am using simple if-else in script, but my requirement is
different for different fields which requires nested or ladder if-else
or switch case, None of these if working with script tag. Can you
please help me out, what is the issue with the query?

Have a look at the custom filters score query - will probably do what
you want more efficiently:

clint

{
"query": {
"custom_score": {
"query": {
"filtered": {
"query": {
"bool": {
"should": [
{
"text": {
"searchable.title": {
"type": "phrase_prefix",
"query": "k",
"analyzer": null
}
}
},
{
"text": {
"searchable.code": {
"type": "phrase_prefix",
"query": "k",
"analyzer": null
}
}
},
{
"text": {
"searchable.zip": {
"type": "phrase_prefix",
"query": "k"
}
}
}
]
}
},
"filter": {
"and": [
{
"term": {
"follower_of_inverse": "34"
}
},
{
"or": [
{
"prefix": {
"searchable.title": "k"
}
},
{
"prefix": {
"searchable.code": "k"
}
},
{
"prefix": {
"searchable.zip": "k"
}
}
]
}
]
}
}
},
"script": {
"script": "if(doc['subtype'].value=='abc') scorepow(10,3);
elseif(doc['subtype'].value=='def')_score
pow(10,0); else _score"
}
}
},
"size": 7
}