# Scoring based off pre-computed scores (function score query + nesting)

**URL:** <https://discuss.elastic.co/t/scoring-based-off-pre-computed-scores-function-score-query-nesting/14280>\
**Category:** Elasticsearch\
**Created:** [November 6, 2013, 4:11am UTC](https://discuss.elastic.co/t/scoring-based-off-pre-computed-scores-function-score-query-nesting/14280 "2013-11-06T04:11:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![benmccann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benmccann/32/420_2.png) [@benmccann](https://discuss.elastic.co/u/benmccann)\
**Post date:** [November 6, 2013, 4:11am UTC](https://discuss.elastic.co/t/scoring-based-off-pre-computed-scores-function-score-query-nesting/14280/1 "2013-11-06T04:11:11Z")

</div>

I'm wondering how I might be able to utilize pre-computed scores. E.g.  
let's say that we're searching for a college to go to and have computed  
scores for some number of attributes. Is there some way I could do custom  
scoring utilizing my precomputed values? The part where I'm getting stuck  
is combining function score query[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html)with a nested  
mapping[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-nested-type.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-nested-type.html)  
.

Any tips?

{  
attributes: [  
{ term: "computer science" , score: 95 },  
{ term: "biology" , score: 67 },  
{ term: "mathematics" , score: 50 },  
{ term: "english" , score: 34 },  
{ term: "football" , score: 69 },  
{ term: "parties" , score: 74 },  
{ term: "graduate pay" , score: 82 },  
]  
}

Thanks,  
Ben

--  
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:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [November 14, 2013, 10:01am UTC](https://discuss.elastic.co/t/scoring-based-off-pre-computed-scores-function-score-query-nesting/14280/2 "2013-11-14T10:01:16Z")

</div>

Hey,

if you take your time to create a gist, which other people can easily run  
locally, the likelihood of getting help is much higher. Also please not  
what you expect and what is not being returned in your queries.

Thanks!

--Alex

On Wed, Nov 6, 2013 at 5:11 AM, Ben McCann [benjamin.j.mccann@gmail.com](mailto:benjamin.j.mccann@gmail.com)wrote:

> I'm wondering how I might be able to utilize pre-computed scores. E.g.  
> let's say that we're searching for a college to go to and have computed  
> scores for some number of attributes. Is there some way I could do custom  
> scoring utilizing my precomputed values? The part where I'm getting stuck  
> is combining function score query[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html)with a nested  
> mapping[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-nested-type.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-nested-type.html)  
> .
> 
> Any tips?
> 
> {  
> attributes: [  
> { term: "computer science" , score: 95 },  
> { term: "biology" , score: 67 },  
> { term: "mathematics" , score: 50 },  
> { term: "english" , score: 34 },  
> { term: "football" , score: 69 },  
> { term: "parties" , score: 74 },  
> { term: "graduate pay" , score: 82 },  
> ]  
> }
> 
> Thanks,  
> Ben
> 
> --  
> 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).

--  
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:** ![Hasham\_Ahmad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hasham_ahmad/32/1939_2.png) [@Hasham\_Ahmad](https://discuss.elastic.co/u/Hasham_Ahmad)\
**Post date:** [November 14, 2013, 1:31pm UTC](https://discuss.elastic.co/t/scoring-based-off-pre-computed-scores-function-score-query-nesting/14280/3 "2013-11-14T13:31:54Z")

</div>

As I understand it nested objects can't be referenced this way because of  
some internal structural behaviour and I was advised to use an array with  
string concatenation ['computer science:95',...] - this then relates to my  
recent question at  
[https://groups.google.com/forum/#!topic/elasticsearch/wq0t2sxBqUA](https://groups.google.com/forum/#!topic/elasticsearch/wq0t2sxBqUA)

Hash

On Wednesday, 6 November 2013 05:11:11 UTC+1, Ben McCann wrote:

> I'm wondering how I might be able to utilize pre-computed scores. E.g.  
> let's say that we're searching for a college to go to and have computed  
> scores for some number of attributes. Is there some way I could do custom  
> scoring utilizing my precomputed values? The part where I'm getting stuck  
> is combining function score query[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html)with a nested  
> mapping[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-nested-type.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-nested-type.html)  
> .
> 
> Any tips?
> 
> {  
> attributes: [  
> { term: "computer science" , score: 95 },  
> { term: "biology" , score: 67 },  
> { term: "mathematics" , score: 50 },  
> { term: "english" , score: 34 },  
> { term: "football" , score: 69 },  
> { term: "parties" , score: 74 },  
> { term: "graduate pay" , score: 82 },  
> ]  
> }
> 
> Thanks,  
> Ben

--  
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:07am UTC](https://discuss.elastic.co/t/scoring-based-off-pre-computed-scores-function-score-query-nesting/14280/4 "2017-07-06T02:07:01Z")

</div>


