Boosting a type

I'm trying to query two types and want to boost on of them!
I have tried this way. But i wan't successful. Can someone help? How can I
do boost a type?

GET /my_index/my_type1,my_type2/_search
{
"query": {
"match": {
"value.autocomplete": "lorem ipsum"
},
"function_score": {
"script_score": {
"script": "doc['_type'].value == 'my_type2' ? _score * 2 : _score"
}
}
}
}

And this is the error i have got

{
"error": "SearchPhaseExecutionException[Failed to execute phase [query],
all shards failed; shardFailures {[3-5dZONwRn2_FJxQr7nGnw][my_index][2]:
SearchParseException[[my_index][2]: query[value.autocomplete:palais
value.autocomplete:stoclet value.autocomplete:sessel],from[-1],size[-1]:
Parse Failure [Failed to parse source [{\n "query": {\n "match":
{\n "value.autocomplete": "Palais Stoclet Sessel"\n },\n
"function_score": {\n "script_score": {\n "script":
"doc['_type'].value == 'my_type2' ? _score * 2 : _score"\n }, \n
"query": {},\n "functions": [\n {}\n ]\n }\n
}\n}\n]]]; nested: ElasticsearchParseException[Expected field name but got
START_OBJECT "function_score"]; }{[3-5dZONwRn2_FJxQr7nGnw][my_index][3]:
SearchParseException[[my_index][3]: query[value.autocomplete:palais
value.autocomplete:stoclet value.autocomplete:sessel],from[-1],size[-1]:
Parse Failure [Failed to parse source [{\n "query": {\n "match":
{\n "value.autocomplete": "Palais Stoclet Sessel"\n },\n
"function_score": {\n "script_score": {\n "script":
"doc['_type'].value == 'my_type2' ? _score * 2 : _score"\n }, \n
"query": {},\n "functions": [\n {}\n ]\n }\n
}\n}\n]]]; nested: ElasticsearchParseException[Expected field name but got
START_OBJECT "function_score"]; }{[3-5dZONwRn2_FJxQr7nGnw][my_index][4]:
SearchParseException[[my_index][4]: query[value.autocomplete:palais
value.autocomplete:stoclet value.autocomplete:sessel],from[-1],size[-1]:
Parse Failure [Failed to parse source [{\n "query": {\n "match":
{\n "value.autocomplete": "Palais Stoclet Sessel"\n },\n
"function_score": {\n "script_score": {\n "script":
"doc['_type'].value == 'my_type2' ? _score * 2 : _score"\n }, \n
"query": {},\n "functions": [\n {}\n ]\n }\n
}\n}\n]]]; nested: ElasticsearchParseException[Expected field name but got
START_OBJECT "function_score"]; }{[3-5dZONwRn2_FJxQr7nGnw][my_index][0]:
SearchParseException[[my_index][0]: query[value.autocomplete:palais
value.autocomplete:stoclet value.autocomplete:sessel],from[-1],size[-1]:
Parse Failure [Failed to parse source [{\n "query": {\n "match":
{\n "value.autocomplete": "Palais Stoclet Sessel"\n },\n
"function_score": {\n "script_score": {\n "script":
"doc['_type'].value == 'my_type2' ? _score * 2 : _score"\n }, \n
"query": {},\n "functions": [\n {}\n ]\n }\n
}\n}\n]]]; nested: ElasticsearchParseException[Expected field name but got
START_OBJECT "function_score"]; }{[3-5dZONwRn2_FJxQr7nGnw][my_index][1]:
SearchParseException[[my_index][1]: query[value.autocomplete:palais
value.autocomplete:stoclet value.autocomplete:sessel],from[-1],size[-1]:
Parse Failure [Failed to parse source [{\n "query": {\n "match":
{\n "value.autocomplete": "Palais Stoclet Sessel"\n },\n
"function_score": {\n "script_score": {\n "script":
"doc['_type'].value == 'my_type2' ? _score * 2 : _score"\n }, \n
"query": {},\n "functions": [\n {}\n ]\n }\n
}\n}\n]]]; nested: ElasticsearchParseException[Expected field name but got
START_OBJECT "function_score"]; }]",
"status": 400
}

Thank you for helping in advance

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e4e6c4f1-a009-4e06-8b2d-0f829846dcf1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

i have solved it in that way...

GET /my_index/my_type1,my_type2/_search
{
"query": {
"function_score": {
"query": {
"match": {
"value.autocomplete": "lorem ipsum"
}
},
"functions": [
{
"script_score": {
"lang": "groovy",
"script": "doc['_type'].value == 'my_type2' ? _score * 2 :
_score"
}
}
]
}
}
}

cheers

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/b56befbd-69a7-47b8-9918-29cdcaa6a062%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

I have yet to switch over to groovy, so I can't comment on where your
current script is wrong (it looks good to me as well). However, you can use
the "standard" function score, which are easier to understand and do not
rely on scripting (technically better performance).

Something like:

"function_score": {
"functions": [
{
"boost_factor": "2",
"filter": {
"terms": {
"_type": [
"my_type2"
]
}
}
}
}
}

--
Ivan

On Wed, Sep 17, 2014 at 7:56 AM, Ramy remram78@gmail.com wrote:

i have solved it in that way...

GET /my_index/my_type1,my_type2/_search
{
"query": {
"function_score": {
"query": {
"match": {
"value.autocomplete": "lorem ipsum"
}
},
"functions": [
{
"script_score": {
"lang": "groovy",
"script": "doc['_type'].value == 'my_type2' ? _score * 2 :
_score"
}
}
]
}
}
}

cheers

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/b56befbd-69a7-47b8-9918-29cdcaa6a062%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/b56befbd-69a7-47b8-9918-29cdcaa6a062%40googlegroups.com?utm_medium=email&utm_source=footer
.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQBky5oo_PoEoKw%3D3J_ih_TrsFpq7E4APgFjjzFTu_V0CQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.