# Boosting a type

**URL:** <https://discuss.elastic.co/t/boosting-a-type/19843>\
**Category:** Elasticsearch\
**Created:** [September 17, 2014, 1:00pm UTC](https://discuss.elastic.co/t/boosting-a-type/19843 "2014-09-17T13:00:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ramy](https://avatars.discourse-cdn.com/v4/letter/r/8491ac/32.png) [@Ramy](https://discuss.elastic.co/u/Ramy)\
**Post date:** [September 17, 2014, 1:00pm UTC](https://discuss.elastic.co/t/boosting-a-type/19843/1 "2014-09-17T13:00:15Z")

</div>

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](mailto: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](https://groups.google.com/d/msgid/elasticsearch/e4e6c4f1-a009-4e06-8b2d-0f829846dcf1%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ramy](https://avatars.discourse-cdn.com/v4/letter/r/8491ac/32.png) [@Ramy](https://discuss.elastic.co/u/Ramy)\
**Post date:** [September 17, 2014, 2:56pm UTC](https://discuss.elastic.co/t/boosting-a-type/19843/2 "2014-09-17T14:56:47Z")

</div>

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](mailto: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).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [September 17, 2014, 3:36pm UTC](https://discuss.elastic.co/t/boosting-a-type/19843/3 "2014-09-17T15:36:08Z")

</div>

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).

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

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](mailto: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](mailto: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)  
> [https://groups.google.com/d/msgid/elasticsearch/b56befbd-69a7-47b8-9918-29cdcaa6a062%40googlegroups.com?utm\_medium=email&utm\_source=footer](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](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](mailto: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](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](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:01am UTC](https://discuss.elastic.co/t/boosting-a-type/19843/4 "2017-07-06T01:01:31Z")

</div>


