# Custom\_score query

**URL:** <https://discuss.elastic.co/t/custom-score-query/11613>\
**Category:** Elasticsearch\
**Created:** [April 17, 2013, 10:31am UTC](https://discuss.elastic.co/t/custom-score-query/11613 "2013-04-17T10:31:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fadel\_Chafai](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fadel_chafai/32/1105_2.png) [@Fadel\_Chafai](https://discuss.elastic.co/u/Fadel_Chafai)\
**Post date:** [April 17, 2013, 10:31am UTC](https://discuss.elastic.co/t/custom-score-query/11613/1 "2013-04-17T10:31:44Z")

</div>

Hello,

I have a strange behavior with a custom\_score query ( normally the script  
applied to the score of the documents returned by the query )

here is my prob:

I have a total of 440 hits with "script": "if (doc ['boost\_category']  
empty == 'false'.) {return doc ['boost\_category'] value \* \_score.} else  
{return \_score} "

and 4977 hits returned using the function: "script": "\_score"

thank you to explain to me this behavior ?

Thank you

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [April 18, 2013, 11:03pm UTC](https://discuss.elastic.co/t/custom-score-query/11613/2 "2013-04-18T23:03:01Z")

</div>

Do you get any shard failures with the more complex script?

On Wednesday, April 17, 2013 6:31:44 AM UTC-4, Fadel Chafai wrote:

> Hello,
> 
> I have a strange behavior with a custom\_score query ( normally the script  
> applied to the score of the documents returned by the query )
> 
> here is my prob:
> 
> I have a total of 440 hits with "script": "if (doc ['boost\_category']  
> empty == 'false'.) {return doc ['boost\_category'] value \* \_score.} else  
> {return \_score} "
> 
> and 4977 hits returned using the function: "script": "\_score"
> 
> thank you to explain to me this behavior ?
> 
> Thank you

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Fadel\_Chafai](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fadel_chafai/32/1105_2.png) [@Fadel\_Chafai](https://discuss.elastic.co/u/Fadel_Chafai)\
**Post date:** [April 25, 2013, 10:53am UTC](https://discuss.elastic.co/t/custom-score-query/11613/3 "2013-04-25T10:53:59Z")

</div>

I'm sorry for the delay, yes exactly I have queries that works but after a  
while they are no longer walking ??????

On Thursday, April 18, 2013 11:03:01 PM UTC, Igor Motov wrote:

> Do you get any shard failures with the more complex script?
> 
> On Wednesday, April 17, 2013 6:31:44 AM UTC-4, Fadel Chafai wrote:
> 
> > Hello,
> > 
> > I have a strange behavior with a custom\_score query ( normally the script  
> > applied to the score of the documents returned by the query )
> > 
> > here is my prob:
> > 
> > I have a total of 440 hits with "script": "if (doc ['boost\_category']  
> > empty == 'false'.) {return doc ['boost\_category'] value \* \_score.} else  
> > {return \_score} "
> > 
> > and 4977 hits returned using the function: "script": "\_score"
> > 
> > thank you to explain to me this behavior ?
> > 
> > Thank you

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [April 25, 2013, 12:17pm UTC](https://discuss.elastic.co/t/custom-score-query/11613/4 "2013-04-25T12:17:24Z")

</div>

How does the failure look like? Can you post the response that you get when  
request fails? Do you see any error messages in the log?

On Thursday, April 25, 2013 12:53:59 PM UTC+2, Fadel Chafai wrote:

> I'm sorry for the delay, yes exactly I have queries that works but after a  
> while they are no longer walking ??????
> 
> On Thursday, April 18, 2013 11:03:01 PM UTC, Igor Motov wrote:
> 
> > Do you get any shard failures with the more complex script?
> > 
> > On Wednesday, April 17, 2013 6:31:44 AM UTC-4, Fadel Chafai wrote:
> > 
> > > Hello,
> > > 
> > > I have a strange behavior with a custom\_score query ( normally the  
> > > script applied to the score of the documents returned by the query )
> > > 
> > > here is my prob:
> > > 
> > > I have a total of 440 hits with "script": "if (doc ['boost\_category']  
> > > empty == 'false'.) {return doc ['boost\_category'] value \* \_score.} else  
> > > {return \_score} "
> > > 
> > > and 4977 hits returned using the function: "script": "\_score"
> > > 
> > > thank you to explain to me this behavior ?
> > > 
> > > Thank you

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:39am UTC](https://discuss.elastic.co/t/custom-score-query/11613/5 "2017-07-06T02:39:40Z")

</div>


