# Elasticsearch Function Score not working with object type

**URL:** <https://discuss.elastic.co/t/elasticsearch-function-score-not-working-with-object-type/19428>\
**Category:** Elasticsearch\
**Created:** [August 25, 2014, 2:27am UTC](https://discuss.elastic.co/t/elasticsearch-function-score-not-working-with-object-type/19428 "2014-08-25T02:27:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pablo\_Musa](https://avatars.discourse-cdn.com/v4/letter/p/34f0e0/32.png) [@Pablo\_Musa](https://discuss.elastic.co/u/Pablo_Musa)\
**Post date:** [August 25, 2014, 2:27am UTC](https://discuss.elastic.co/t/elasticsearch-function-score-not-working-with-object-type/19428/1 "2014-08-25T02:27:09Z")

</div>

Hey guys,  
I am trying to use the function score but I am getting the following error:

ElasticsearchIllegalArgumentException[No field found for [fsot] in mapping  
with types [tst]];

I have used function score before and it worked like a charm so I started  
digging what was wrong. I found out that it does not work with object type.

Am I doing something wrong? What am I missing here?

The following gist contains an example and the error I received.

> <https://gist.github.com/pmusa/ef9a02210d736ee020d9>

Thanks in advance,  
Pablo Musa

--  
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/CAF6PhF%2B5A3XYCHhFm\_j-rFuXLAz3tE\_xAUCcdV2UbFASwCx52Q%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAF6PhF%2B5A3XYCHhFm_j-rFuXLAz3tE_xAUCcdV2UbFASwCx52Q%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineeth_mohan_2/32/747_2.png) [@vineeth\_mohan\_2](https://discuss.elastic.co/u/vineeth_mohan_2)\
**Post date:** [August 25, 2014, 3:33am UTC](https://discuss.elastic.co/t/elasticsearch-function-score-not-working-with-object-type/19428/2 "2014-08-25T03:33:25Z")

</div>

Hello Pablo ,

Lucene ( the underlying library library on which ES is build upon) has only  
key value concept and it does not keep object level information.  
This means that on Lucene side , data would be stored as

fsot.testObjects : ["test1" , "test2"]

And there is not field names as fsot on lucene side.  
This means that you need to give the field name as fsot.testObjects rather  
than fsot.

Thanks  
Vineeth

On Mon, Aug 25, 2014 at 7:57 AM, Pablo Musa [pablitomusa@gmail.com](mailto:pablitomusa@gmail.com) wrote:

> Hey guys,  
> I am trying to use the function score but I am getting the following error:
> 
> ElasticsearchIllegalArgumentException[No field found for [fsot] in mapping  
> with types [tst]];
> 
> I have used function score before and it worked like a charm so I started  
> digging what was wrong. I found out that it does not work with object type.
> 
> Am I doing something wrong? What am I missing here?
> 
> The following gist contains an example and the error I received.  
> [Elasticsearch Function Score does not work with fields of object type. · GitHub](https://gist.github.com/pmusa/ef9a02210d736ee020d9)
> 
> Thanks in advance,  
> Pablo Musa
> 
> --  
> 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/CAF6PhF%2B5A3XYCHhFm\_j-rFuXLAz3tE\_xAUCcdV2UbFASwCx52Q%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAF6PhF%2B5A3XYCHhFm_j-rFuXLAz3tE_xAUCcdV2UbFASwCx52Q%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CAF6PhF%2B5A3XYCHhFm\_j-rFuXLAz3tE\_xAUCcdV2UbFASwCx52Q%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAF6PhF%2B5A3XYCHhFm_j-rFuXLAz3tE_xAUCcdV2UbFASwCx52Q%40mail.gmail.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/CAGdPd5miTeN1xCHHz%2ByOLxoOX%2BwkOq8TAFgXFYrx6ziaJa%3DJ%2Bw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5miTeN1xCHHz%2ByOLxoOX%2BwkOq8TAFgXFYrx6ziaJa%3DJ%2Bw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Pablo\_Musa](https://avatars.discourse-cdn.com/v4/letter/p/34f0e0/32.png) [@Pablo\_Musa](https://discuss.elastic.co/u/Pablo_Musa)\
**Post date:** [August 25, 2014, 3:51am UTC](https://discuss.elastic.co/t/elasticsearch-function-score-not-working-with-object-type/19428/3 "2014-08-25T03:51:23Z")

</div>

It worked. Thank you very much.

- copying the final code for future referece:

POST test/tst/\_search  
{  
"query": {  
"function\_score": {  
"boost\_mode": "replace",  
"query": {  
"filtered": {  
"query": {  
"match\_all": {}  
},  
"filter": {  
"exists": {  
"field": "fsot"  
}  
}  
}  
},  
"functions": [  
{  
"script\_score": {  
"script": "if ( doc.get('fsot.testobj') == null ) 0; else 1;"  
}  
}  
]  
}  
}  
}

On Monday, August 25, 2014 12:33:47 AM UTC-3, vineeth mohan wrote:

> Hello Pablo ,
> 
> Lucene ( the underlying library library on which ES is build upon) has  
> only key value concept and it does not keep object level information.  
> This means that on Lucene side , data would be stored as
> 
> fsot.testObjects : ["test1" , "test2"]
> 
> And there is not field names as fsot on lucene side.  
> This means that you need to give the field name as fsot.testObjects rather  
> than fsot.
> 
> Thanks  
> Vineeth
> 
> On Mon, Aug 25, 2014 at 7:57 AM, Pablo Musa \<[pabli...@gmail.com](mailto:pabli...@gmail.com)  
> \<javascript:\>\> wrote:
> 
> > Hey guys,  
> > I am trying to use the function score but I am getting the following  
> > error:
> > 
> > ElasticsearchIllegalArgumentException[No field found for [fsot] in  
> > mapping with types [tst]];
> > 
> > I have used function score before and it worked like a charm so I started  
> > digging what was wrong. I found out that it does not work with object type.
> > 
> > Am I doing something wrong? What am I missing here?
> > 
> > The following gist contains an example and the error I received.  
> > [Elasticsearch Function Score does not work with fields of object type. · GitHub](https://gist.github.com/pmusa/ef9a02210d736ee020d9)
> > 
> > Thanks in advance,  
> > Pablo Musa
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CAF6PhF%2B5A3XYCHhFm\_j-rFuXLAz3tE\_xAUCcdV2UbFASwCx52Q%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAF6PhF%2B5A3XYCHhFm_j-rFuXLAz3tE_xAUCcdV2UbFASwCx52Q%40mail.gmail.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/CAF6PhF%2B5A3XYCHhFm\_j-rFuXLAz3tE\_xAUCcdV2UbFASwCx52Q%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAF6PhF%2B5A3XYCHhFm_j-rFuXLAz3tE_xAUCcdV2UbFASwCx52Q%40mail.gmail.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/bf051fbb-a860-4898-864b-fedb54c8500c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/bf051fbb-a860-4898-864b-fedb54c8500c%40googlegroups.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:06am UTC](https://discuss.elastic.co/t/elasticsearch-function-score-not-working-with-object-type/19428/4 "2017-07-06T01:06:46Z")

</div>


