# How can we use elasticsearch custom similarity plugin in mapping?

**URL:** <https://discuss.elastic.co/t/how-can-we-use-elasticsearch-custom-similarity-plugin-in-mapping/15247>\
**Category:** Elasticsearch\
**Created:** [January 15, 2014, 3:59pm UTC](https://discuss.elastic.co/t/how-can-we-use-elasticsearch-custom-similarity-plugin-in-mapping/15247 "2014-01-15T15:59:17Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![dark\_shadow](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dark\_shadow](https://discuss.elastic.co/u/dark_shadow)\
**Post date:** [January 15, 2014, 3:59pm UTC](https://discuss.elastic.co/t/how-can-we-use-elasticsearch-custom-similarity-plugin-in-mapping/15247/1 "2014-01-15T15:59:17Z")

</div>

Hi,

I need to override Lucene Default Similarity Class which is used by  
Elasticsearch for indexing and searching. On searching net, I found some  
similar implementations which are doing similar things. My difficulty is  
that I have no idea of how to actually implement this in my code. I found  
some resources:

> **[tlrx/elasticsearch-custom-similarity-provider](https://github.com/tlrx/elasticsearch-custom-similarity-provider)**
>
> elasticsearch-custom-similarity-provider - A custom SimilarityProvider example for Elasticsearch

curl -XPOST '[http://host](http://host):port/tweeter/' -d '{  
"settings": {  
"similarity": {  
"index": {  
"type": "org.elasticsearch.index.similarity.CustomSimilarityProvider"  
},  
"search": {  
"type": "org.elasticsearch.index.similarity.CustomSimilarityProvider"  
}  
}  
}}'

I'm not able to understand how can i use this line directly during indexing  
so that my default similarity changes to this custom similarity.

_org.elasticsearch.index.similarity.CustomSimilarityProvider_

Can anyone please tell me how I can do this ? I tried running the same  
thing on my machine but it's not working for me. Do I need to modify this  
line or path ?

Thanks 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/18cb1da8-7c4c-4ea0-b5b1-10b6f81880b0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/18cb1da8-7c4c-4ea0-b5b1-10b6f81880b0%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [January 15, 2014, 5:05pm UTC](https://discuss.elastic.co/t/how-can-we-use-elasticsearch-custom-similarity-plugin-in-mapping/15247/2 "2014-01-15T17:05:47Z")

</div>

The plugin is outdated.

You can override similarity by standard ES 0.90+

[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-similarity.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-similarity.html)

Jörg

--  
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/CAKdsXoEMeNc4MpEO82L6KfLFsZziqdUO8F1LoRMgq3NrSyucqg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEMeNc4MpEO82L6KfLFsZziqdUO8F1LoRMgq3NrSyucqg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dark\_shadow](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dark\_shadow](https://discuss.elastic.co/u/dark_shadow)\
**Post date:** [January 15, 2014, 5:17pm UTC](https://discuss.elastic.co/t/how-can-we-use-elasticsearch-custom-similarity-plugin-in-mapping/15247/3 "2014-01-15T17:17:39Z")

</div>

I have read about that module but the thing is I have to set idf to 1.  
Actually, I want common terms to give more weight in my search. Now, when I  
googled about it, it says overriding the default similarity class is the  
only way to achieve it. That's the reason why I'm looking for these plugins.

On Wed, Jan 15, 2014 at 10:35 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
[joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:

> The plugin is outdated.
> 
> You can override similarity by standard ES 0.90+
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-similarity.html)
> 
> Jörg
> 
> --  
> 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/CAKdsXoEMeNc4MpEO82L6KfLFsZziqdUO8F1LoRMgq3NrSyucqg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEMeNc4MpEO82L6KfLFsZziqdUO8F1LoRMgq3NrSyucqg%40mail.gmail.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAAVTvp5vDnq7w4rkA7CWNJUNpHmG9ztYdiN5u%3D1tj-%3DjvJSMUQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAVTvp5vDnq7w4rkA7CWNJUNpHmG9ztYdiN5u%3D1tj-%3DjvJSMUQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [January 15, 2014, 5:52pm UTC](https://discuss.elastic.co/t/how-can-we-use-elasticsearch-custom-similarity-plugin-in-mapping/15247/4 "2014-01-15T17:52:46Z")

</div>

I have looked into that similarity plugin in the past and as far as I can  
tell, it is partially wrong. Judging by the elasticsearch code, there is no  
way to change the similarity depending if you are indexing or querying. The  
similarity is simply tied to a field and it is used at all times. Someone  
please correct me if I am wrong.

Besides that, writing your own similarity plugin is simple. You just need  
one class extending AbstractSimilarityProvider and another class with the  
actual similarity, which probably extends DefaultSimilarity. No need for a  
plugin, you just need the classes in the elasticsearch classpath at startup.

Cheers,

Ivan

On Wed, Jan 15, 2014 at 9:17 AM, Mukul Gupta [mukulnitkkr@gmail.com](mailto:mukulnitkkr@gmail.com) wrote:

> I have read about that module but the thing is I have to set idf to 1.  
> Actually, I want common terms to give more weight in my search. Now, when I  
> googled about it, it says overriding the default similarity class is the  
> only way to achieve it. That's the reason why I'm looking for these plugins.
> 
> On Wed, Jan 15, 2014 at 10:35 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
> [joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:
> 
> > The plugin is outdated.
> > 
> > You can override similarity by standard ES 0.90+
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-similarity.html)
> > 
> > Jörg
> > 
> > --  
> > 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/CAKdsXoEMeNc4MpEO82L6KfLFsZziqdUO8F1LoRMgq3NrSyucqg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEMeNc4MpEO82L6KfLFsZziqdUO8F1LoRMgq3NrSyucqg%40mail.gmail.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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAAVTvp5vDnq7w4rkA7CWNJUNpHmG9ztYdiN5u%3D1tj-%3DjvJSMUQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAVTvp5vDnq7w4rkA7CWNJUNpHmG9ztYdiN5u%3D1tj-%3DjvJSMUQ%40mail.gmail.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQD8OXROhz4R1oMaL6TbcvjEhQdRh8sFvNpcxgc\_2Y3VSA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQD8OXROhz4R1oMaL6TbcvjEhQdRh8sFvNpcxgc_2Y3VSA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [January 15, 2014, 6:53pm UTC](https://discuss.elastic.co/t/how-can-we-use-elasticsearch-custom-similarity-plugin-in-mapping/15247/5 "2014-01-15T18:53:12Z")

</div>

Why don't you use function score if you only want to tweak parameters?

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

Changing similarity is a massive change, it's exchanging the whole  
algorithm. Not recommended unless you can't get what you want from function  
score.

Jörg

--  
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/CAKdsXoEOLeH\_HhB4Lf9eg7OEtGK9w6Nk7vpoH9CU97D%2BSyRbig%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEOLeH_HhB4Lf9eg7OEtGK9w6Nk7vpoH9CU97D%2BSyRbig%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [January 15, 2014, 6:58pm UTC](https://discuss.elastic.co/t/how-can-we-use-elasticsearch-custom-similarity-plugin-in-mapping/15247/6 "2014-01-15T18:58:47Z")

</div>

I was focused on how to use a custom similarity and not how to actually  
tackle the problem. In this respect, I agree with Jörg. Also, I believe the  
today's release (1.0.0.RC1) has additional scripting options:

> **[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.

Cheers,

Ivan

On Wed, Jan 15, 2014 at 10:53 AM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
[joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:

> Why don't you use function score if you only want to tweak parameters?
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html)
> 
> Changing similarity is a massive change, it's exchanging the whole  
> algorithm. Not recommended unless you can't get what you want from function  
> score.
> 
> Jörg
> 
> --  
> 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/CAKdsXoEOLeH\_HhB4Lf9eg7OEtGK9w6Nk7vpoH9CU97D%2BSyRbig%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEOLeH_HhB4Lf9eg7OEtGK9w6Nk7vpoH9CU97D%2BSyRbig%40mail.gmail.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQAiU2RK9vbpDxemDn15VbuKOV0ujCxGiuPNGVZxs-dC-g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQAiU2RK9vbpDxemDn15VbuKOV0ujCxGiuPNGVZxs-dC-g%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dark\_shadow](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dark\_shadow](https://discuss.elastic.co/u/dark_shadow)\
**Post date:** [January 16, 2014, 5:14am UTC](https://discuss.elastic.co/t/how-can-we-use-elasticsearch-custom-similarity-plugin-in-mapping/15247/7 "2014-01-16T05:14:33Z")

</div>

Hi Ivan,

Can you please tell me how can I add the above mentioned classes in my  
elasticsearch classpath ?

Thanks

On Wed, Jan 15, 2014 at 11:22 PM, Ivan Brusic [ivan@brusic.com](mailto:ivan@brusic.com) wrote:

> I have looked into that similarity plugin in the past and as far as I can  
> tell, it is partially wrong. Judging by the elasticsearch code, there is no  
> way to change the similarity depending if you are indexing or querying. The  
> similarity is simply tied to a field and it is used at all times. Someone  
> please correct me if I am wrong.
> 
> Besides that, writing your own similarity plugin is simple. You just need  
> one class extending AbstractSimilarityProvider and another class with the  
> actual similarity, which probably extends DefaultSimilarity. No need for a  
> plugin, you just need the classes in the elasticsearch classpath at startup.
> 
> Cheers,
> 
> Ivan
> 
> On Wed, Jan 15, 2014 at 9:17 AM, Mukul Gupta [mukulnitkkr@gmail.com](mailto:mukulnitkkr@gmail.com)wrote:
> 
> > I have read about that module but the thing is I have to set idf to 1.  
> > Actually, I want common terms to give more weight in my search. Now, when I  
> > googled about it, it says overriding the default similarity class is the  
> > only way to achieve it. That's the reason why I'm looking for these plugins.
> > 
> > On Wed, Jan 15, 2014 at 10:35 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
> > [joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:
> > 
> > > The plugin is outdated.
> > > 
> > > You can override similarity by standard ES 0.90+
> > > 
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-similarity.html)
> > > 
> > > Jörg
> > > 
> > > --  
> > > 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/CAKdsXoEMeNc4MpEO82L6KfLFsZziqdUO8F1LoRMgq3NrSyucqg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEMeNc4MpEO82L6KfLFsZziqdUO8F1LoRMgq3NrSyucqg%40mail.gmail.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).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CAAVTvp5vDnq7w4rkA7CWNJUNpHmG9ztYdiN5u%3D1tj-%3DjvJSMUQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAVTvp5vDnq7w4rkA7CWNJUNpHmG9ztYdiN5u%3D1tj-%3DjvJSMUQ%40mail.gmail.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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQD8OXROhz4R1oMaL6TbcvjEhQdRh8sFvNpcxgc\_2Y3VSA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQD8OXROhz4R1oMaL6TbcvjEhQdRh8sFvNpcxgc_2Y3VSA%40mail.gmail.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAAVTvp43PYoBfzThbQSMpDfn-VFz\_KgHaT7whYC6msSD2%3DcQwQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAVTvp43PYoBfzThbQSMpDfn-VFz_KgHaT7whYC6msSD2%3DcQwQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dark\_shadow](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dark\_shadow](https://discuss.elastic.co/u/dark_shadow)\
**Post date:** [January 16, 2014, 5:16am UTC](https://discuss.elastic.co/t/how-can-we-use-elasticsearch-custom-similarity-plugin-in-mapping/15247/8 "2014-01-16T05:16:31Z")

</div>

Hi Jörg,

Let's say I want to modify my \_score in such a way that it doesn't take  
into consideration idf while calculating score. How can I achieve this  
using function score ? Can you give me some example usage of function score  
which takes only tf into consideration.

Thanks

On Thu, Jan 16, 2014 at 12:23 AM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
[joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:

> Why don't you use function score if you only want to tweak parameters?
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html)
> 
> Changing similarity is a massive change, it's exchanging the whole  
> algorithm. Not recommended unless you can't get what you want from function  
> score.
> 
> Jörg
> 
> --  
> 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/CAKdsXoEOLeH\_HhB4Lf9eg7OEtGK9w6Nk7vpoH9CU97D%2BSyRbig%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEOLeH_HhB4Lf9eg7OEtGK9w6Nk7vpoH9CU97D%2BSyRbig%40mail.gmail.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAAVTvp51QDJ2OBnhfPEEX6XWjOrh9E5k2f%3Dgg4xGx2qNJtM8GA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAVTvp51QDJ2OBnhfPEEX6XWjOrh9E5k2f%3Dgg4xGx2qNJtM8GA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [January 16, 2014, 8:18am UTC](https://discuss.elastic.co/t/how-can-we-use-elasticsearch-custom-similarity-plugin-in-mapping/15247/9 "2014-01-16T08:18:57Z")

</div>

I don't know how to do this by function score, but have you looked at it?

Jörg

--  
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/CAKdsXoGL0ocjJKg2eJqRS%3DZVOzVnuus-42m%2Bhk6-b7Mumuv\_Bg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGL0ocjJKg2eJqRS%3DZVOzVnuus-42m%2Bhk6-b7Mumuv_Bg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [January 16, 2014, 11:46am UTC](https://discuss.elastic.co/t/how-can-we-use-elasticsearch-custom-similarity-plugin-in-mapping/15247/10 "2014-01-16T11:46:17Z")

</div>

Using the function\_score you could use a script. Since 0.90.10 you can  
access term statistics from a script  
([Add support for using payloads to boost terms · Issue #3772 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/3772)), term  
frequency included. You could for instance emit your own score that takes  
into account only the term frequency but not the idf.

On Thursday, January 16, 2014 9:18:57 AM UTC+1, Jörg Prante wrote:

> I don't know how to do this by function score, but have you looked at it?
> 
> Jörg

--  
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/1db8d628-dddd-4150-a2bd-64fcd7839cd0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1db8d628-dddd-4150-a2bd-64fcd7839cd0%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dark\_shadow](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dark\_shadow](https://discuss.elastic.co/u/dark_shadow)\
**Post date:** [January 16, 2014, 12:43pm UTC](https://discuss.elastic.co/t/how-can-we-use-elasticsearch-custom-similarity-plugin-in-mapping/15247/11 "2014-01-16T12:43:50Z")

</div>

Is there any java api available for function\_score ?

On Thu, Jan 16, 2014 at 5:16 PM, Luca Cavanna [cavannaluca@gmail.com](mailto:cavannaluca@gmail.com) wrote:

> Using the function\_score you could use a script. Since 0.90.10 you can  
> access term statistics from a script (  
> [Add support for using payloads to boost terms · Issue #3772 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/3772)), term  
> frequency included. You could for instance emit your own score that takes  
> into account only the term frequency but not the idf.
> 
> On Thursday, January 16, 2014 9:18:57 AM UTC+1, Jörg Prante wrote:
> 
> > I don't know how to do this by function score, but have you looked at it?
> > 
> > Jörg
> > 
> > --  
> > 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/1db8d628-dddd-4150-a2bd-64fcd7839cd0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1db8d628-dddd-4150-a2bd-64fcd7839cd0%40googlegroups.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAAVTvp6rZ3yrTL8RMTpzS78-W\_GKb7Oj2nED7jTiTfWEzw9amg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAVTvp6rZ3yrTL8RMTpzS78-W_GKb7Oj2nED7jTiTfWEzw9amg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [January 16, 2014, 12:56pm UTC](https://discuss.elastic.co/t/how-can-we-use-elasticsearch-custom-similarity-plugin-in-mapping/15247/12 "2014-01-16T12:56:44Z")

</div>

Not sure what you mean, the function score is a query that is part of the  
query DSL. If you are using the java API, you can find the usual query  
builder, called FunctionScoreQueryBuilder or even use the handy  
QueryBuilders static methods to create one.

On Thu, Jan 16, 2014 at 1:43 PM, Mukul Gupta [mukulnitkkr@gmail.com](mailto:mukulnitkkr@gmail.com) wrote:

> Is there any java api available for function\_score ?
> 
> On Thu, Jan 16, 2014 at 5:16 PM, Luca Cavanna [cavannaluca@gmail.com](mailto:cavannaluca@gmail.com)wrote:
> 
> > Using the function\_score you could use a script. Since 0.90.10 you can  
> > access term statistics from a script (  
> > [Add support for using payloads to boost terms · Issue #3772 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/3772)), term  
> > frequency included. You could for instance emit your own score that takes  
> > into account only the term frequency but not the idf.
> > 
> > On Thursday, January 16, 2014 9:18:57 AM UTC+1, Jörg Prante wrote:
> > 
> > > I don't know how to do this by function score, but have you looked at it?
> > > 
> > > Jörg
> > > 
> > > --  
> > > 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/1db8d628-dddd-4150-a2bd-64fcd7839cd0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1db8d628-dddd-4150-a2bd-64fcd7839cd0%40googlegroups.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 a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/1tB6yB0m10o/unsubscribe](https://groups.google.com/d/topic/elasticsearch/1tB6yB0m10o/unsubscribe).  
> To unsubscribe from this group and all its topics, 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/CAAVTvp6rZ3yrTL8RMTpzS78-W\_GKb7Oj2nED7jTiTfWEzw9amg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAVTvp6rZ3yrTL8RMTpzS78-W_GKb7Oj2nED7jTiTfWEzw9amg%40mail.gmail.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CADdZ9MWh0f49t5ek9aaKA5AeEgaJEsfwc4XAqaqB5Cbibc0vig%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CADdZ9MWh0f49t5ek9aaKA5AeEgaJEsfwc4XAqaqB5Cbibc0vig%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dark\_shadow](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dark\_shadow](https://discuss.elastic.co/u/dark_shadow)\
**Post date:** [January 16, 2014, 1:21pm UTC](https://discuss.elastic.co/t/how-can-we-use-elasticsearch-custom-similarity-plugin-in-mapping/15247/13 "2014-01-16T13:21:03Z")

</div>

I tried using FunctionScoreQueryBuilders but there is no such thing  
available with me. Do I need to use any package for this ?

On Thu, Jan 16, 2014 at 6:26 PM, Luca Cavanna [cavannaluca@gmail.com](mailto:cavannaluca@gmail.com) wrote:

> Not sure what you mean, the function score is a query that is part of the  
> query DSL. If you are using the java API, you can find the usual query  
> builder, called FunctionScoreQueryBuilder or even use the handy  
> QueryBuilders static methods to create one.
> 
> On Thu, Jan 16, 2014 at 1:43 PM, Mukul Gupta [mukulnitkkr@gmail.com](mailto:mukulnitkkr@gmail.com)wrote:
> 
> > Is there any java api available for function\_score ?
> > 
> > On Thu, Jan 16, 2014 at 5:16 PM, Luca Cavanna [cavannaluca@gmail.com](mailto:cavannaluca@gmail.com)wrote:
> > 
> > > Using the function\_score you could use a script. Since 0.90.10 you can  
> > > access term statistics from a script (  
> > > [Add support for using payloads to boost terms · Issue #3772 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/3772)), term  
> > > frequency included. You could for instance emit your own score that takes  
> > > into account only the term frequency but not the idf.
> > > 
> > > On Thursday, January 16, 2014 9:18:57 AM UTC+1, Jörg Prante wrote:
> > > 
> > > > I don't know how to do this by function score, but have you looked at  
> > > > it?
> > > > 
> > > > Jörg
> > > > 
> > > > --  
> > > > 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/1db8d628-dddd-4150-a2bd-64fcd7839cd0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1db8d628-dddd-4150-a2bd-64fcd7839cd0%40googlegroups.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 a topic in the  
> > Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/elasticsearch/1tB6yB0m10o/unsubscribe](https://groups.google.com/d/topic/elasticsearch/1tB6yB0m10o/unsubscribe).  
> > To unsubscribe from this group and all its topics, 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/CAAVTvp6rZ3yrTL8RMTpzS78-W\_GKb7Oj2nED7jTiTfWEzw9amg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAVTvp6rZ3yrTL8RMTpzS78-W_GKb7Oj2nED7jTiTfWEzw9amg%40mail.gmail.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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CADdZ9MWh0f49t5ek9aaKA5AeEgaJEsfwc4XAqaqB5Cbibc0vig%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CADdZ9MWh0f49t5ek9aaKA5AeEgaJEsfwc4XAqaqB5Cbibc0vig%40mail.gmail.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAAVTvp7t6P16U0bb1DP0%2Bz%3DgS6dBjMfpCpbNw5WSmeXSHsYCHQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAVTvp7t6P16U0bb1DP0%2Bz%3DgS6dBjMfpCpbNw5WSmeXSHsYCHQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [January 16, 2014, 1:26pm UTC](https://discuss.elastic.co/t/how-can-we-use-elasticsearch-custom-similarity-plugin-in-mapping/15247/14 "2014-01-16T13:26:23Z")

</div>

I guess you are using a not so recent version of elasticsearch then. Which  
version are you working on?

On Thu, Jan 16, 2014 at 2:21 PM, Mukul Gupta [mukulnitkkr@gmail.com](mailto:mukulnitkkr@gmail.com) wrote:

> I tried using FunctionScoreQueryBuilders but there is no such thing  
> available with me. Do I need to use any package for this ?
> 
> On Thu, Jan 16, 2014 at 6:26 PM, Luca Cavanna [cavannaluca@gmail.com](mailto:cavannaluca@gmail.com)wrote:
> 
> > Not sure what you mean, the function score is a query that is part of the  
> > query DSL. If you are using the java API, you can find the usual query  
> > builder, called FunctionScoreQueryBuilder or even use the handy  
> > QueryBuilders static methods to create one.
> > 
> > On Thu, Jan 16, 2014 at 1:43 PM, Mukul Gupta [mukulnitkkr@gmail.com](mailto:mukulnitkkr@gmail.com)wrote:
> > 
> > > Is there any java api available for function\_score ?
> > > 
> > > On Thu, Jan 16, 2014 at 5:16 PM, Luca Cavanna [cavannaluca@gmail.com](mailto:cavannaluca@gmail.com)wrote:
> > > 
> > > > Using the function\_score you could use a script. Since 0.90.10 you can  
> > > > access term statistics from a script (  
> > > > [Add support for using payloads to boost terms · Issue #3772 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/3772)), term  
> > > > frequency included. You could for instance emit your own score that takes  
> > > > into account only the term frequency but not the idf.
> > > > 
> > > > On Thursday, January 16, 2014 9:18:57 AM UTC+1, Jörg Prante wrote:
> > > > 
> > > > > I don't know how to do this by function score, but have you looked at  
> > > > > it?
> > > > > 
> > > > > Jörg
> > > > > 
> > > > > --  
> > > > > 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/1db8d628-dddd-4150-a2bd-64fcd7839cd0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1db8d628-dddd-4150-a2bd-64fcd7839cd0%40googlegroups.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 a topic in the  
> > > Google Groups "elasticsearch" group.  
> > > To unsubscribe from this topic, visit  
> > > [https://groups.google.com/d/topic/elasticsearch/1tB6yB0m10o/unsubscribe](https://groups.google.com/d/topic/elasticsearch/1tB6yB0m10o/unsubscribe).  
> > > To unsubscribe from this group and all its topics, 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/CAAVTvp6rZ3yrTL8RMTpzS78-W\_GKb7Oj2nED7jTiTfWEzw9amg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAVTvp6rZ3yrTL8RMTpzS78-W_GKb7Oj2nED7jTiTfWEzw9amg%40mail.gmail.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).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CADdZ9MWh0f49t5ek9aaKA5AeEgaJEsfwc4XAqaqB5Cbibc0vig%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CADdZ9MWh0f49t5ek9aaKA5AeEgaJEsfwc4XAqaqB5Cbibc0vig%40mail.gmail.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 a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/1tB6yB0m10o/unsubscribe](https://groups.google.com/d/topic/elasticsearch/1tB6yB0m10o/unsubscribe).  
> To unsubscribe from this group and all its topics, 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/CAAVTvp7t6P16U0bb1DP0%2Bz%3DgS6dBjMfpCpbNw5WSmeXSHsYCHQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAVTvp7t6P16U0bb1DP0%2Bz%3DgS6dBjMfpCpbNw5WSmeXSHsYCHQ%40mail.gmail.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CADdZ9MVNbuqDw%3DDHbvzprLvhM%2BT-UWFQwaLm1bX-qsgTzVzf4Q%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CADdZ9MVNbuqDw%3DDHbvzprLvhM%2BT-UWFQwaLm1bX-qsgTzVzf4Q%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dark\_shadow](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dark\_shadow](https://discuss.elastic.co/u/dark_shadow)\
**Post date:** [January 16, 2014, 1:54pm UTC](https://discuss.elastic.co/t/how-can-we-use-elasticsearch-custom-similarity-plugin-in-mapping/15247/15 "2014-01-16T13:54:26Z")

</div>

My bad. I'm using elasticsearch-0.90.3. I guess it's not available in this  
version.

On Thu, Jan 16, 2014 at 6:56 PM, Luca Cavanna [cavannaluca@gmail.com](mailto:cavannaluca@gmail.com) wrote:

> I guess you are using a not so recent version of elasticsearch then. Which  
> version are you working on?
> 
> On Thu, Jan 16, 2014 at 2:21 PM, Mukul Gupta [mukulnitkkr@gmail.com](mailto:mukulnitkkr@gmail.com)wrote:
> 
> > I tried using FunctionScoreQueryBuilders but there is no such thing  
> > available with me. Do I need to use any package for this ?
> > 
> > On Thu, Jan 16, 2014 at 6:26 PM, Luca Cavanna [cavannaluca@gmail.com](mailto:cavannaluca@gmail.com)wrote:
> > 
> > > Not sure what you mean, the function score is a query that is part of  
> > > the query DSL. If you are using the java API, you can find the usual query  
> > > builder, called FunctionScoreQueryBuilder or even use the handy  
> > > QueryBuilders static methods to create one.
> > > 
> > > On Thu, Jan 16, 2014 at 1:43 PM, Mukul Gupta [mukulnitkkr@gmail.com](mailto:mukulnitkkr@gmail.com)wrote:
> > > 
> > > > Is there any java api available for function\_score ?
> > > > 
> > > > On Thu, Jan 16, 2014 at 5:16 PM, Luca Cavanna [cavannaluca@gmail.com](mailto:cavannaluca@gmail.com)wrote:
> > > > 
> > > > > Using the function\_score you could use a script. Since 0.90.10 you can  
> > > > > access term statistics from a script (  
> > > > > [Add support for using payloads to boost terms · Issue #3772 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/3772)), term  
> > > > > frequency included. You could for instance emit your own score that takes  
> > > > > into account only the term frequency but not the idf.
> > > > > 
> > > > > On Thursday, January 16, 2014 9:18:57 AM UTC+1, Jörg Prante wrote:
> > > > > 
> > > > > > I don't know how to do this by function score, but have you looked at  
> > > > > > it?
> > > > > > 
> > > > > > Jörg
> > > > > > 
> > > > > > --  
> > > > > > 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/1db8d628-dddd-4150-a2bd-64fcd7839cd0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1db8d628-dddd-4150-a2bd-64fcd7839cd0%40googlegroups.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 a topic in the  
> > > > Google Groups "elasticsearch" group.  
> > > > To unsubscribe from this topic, visit  
> > > > [https://groups.google.com/d/topic/elasticsearch/1tB6yB0m10o/unsubscribe](https://groups.google.com/d/topic/elasticsearch/1tB6yB0m10o/unsubscribe)  
> > > > .  
> > > > To unsubscribe from this group and all its topics, 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/CAAVTvp6rZ3yrTL8RMTpzS78-W\_GKb7Oj2nED7jTiTfWEzw9amg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAVTvp6rZ3yrTL8RMTpzS78-W_GKb7Oj2nED7jTiTfWEzw9amg%40mail.gmail.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).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/CADdZ9MWh0f49t5ek9aaKA5AeEgaJEsfwc4XAqaqB5Cbibc0vig%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CADdZ9MWh0f49t5ek9aaKA5AeEgaJEsfwc4XAqaqB5Cbibc0vig%40mail.gmail.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 a topic in the  
> > Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/elasticsearch/1tB6yB0m10o/unsubscribe](https://groups.google.com/d/topic/elasticsearch/1tB6yB0m10o/unsubscribe).  
> > To unsubscribe from this group and all its topics, 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/CAAVTvp7t6P16U0bb1DP0%2Bz%3DgS6dBjMfpCpbNw5WSmeXSHsYCHQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAVTvp7t6P16U0bb1DP0%2Bz%3DgS6dBjMfpCpbNw5WSmeXSHsYCHQ%40mail.gmail.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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CADdZ9MVNbuqDw%3DDHbvzprLvhM%2BT-UWFQwaLm1bX-qsgTzVzf4Q%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CADdZ9MVNbuqDw%3DDHbvzprLvhM%2BT-UWFQwaLm1bX-qsgTzVzf4Q%40mail.gmail.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAAVTvp5BFRsSr30hDEjr%3DPb0bFXiL2\_iOvMxaEShNU-dc7xV5g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAVTvp5BFRsSr30hDEjr%3DPb0bFXiL2_iOvMxaEShNU-dc7xV5g%40mail.gmail.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, 1:56am UTC](https://discuss.elastic.co/t/how-can-we-use-elasticsearch-custom-similarity-plugin-in-mapping/15247/16 "2017-07-06T01:56:23Z")

</div>


