# Filter by match\_phrase, score by phrase frequency

**URL:** https://discuss.elastic.co/t/filter-by-match-phrase-score-by-phrase-frequency/57583
**Category:** Elasticsearch
**Created:** [August 9, 2016, 10:36am UTC](https://discuss.elastic.co/t/filter-by-match-phrase-score-by-phrase-frequency/57583 "2016-08-09T10:36:57Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![viktorm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/viktorm/32/11279_2.png) [@viktorm](https://discuss.elastic.co/u/viktorm)
#### Post date: [August 9, 2016, 10:36am UTC](https://discuss.elastic.co/t/filter-by-match-phrase-score-by-phrase-frequency/57583/1 "2016-08-09T10:36:57Z")

</div>

Hi there!

I want to score document relevance by exact phrase frequency in a field. Some queries have multiple phrases for filtering. Is there any better way than scripting a custom score function?

UPD: My experiments with scripted score function and shingles [http://lpaste.net/2853889383168212992](http://lpaste.net/2853889383168212992). So far scripted solution works best. However I'm unsure about performance impact.

Thanks!

---

<div class="post-metadata">

### Author: ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)
#### Post date: [August 9, 2016, 9:12pm UTC](https://discuss.elastic.co/t/filter-by-match-phrase-score-by-phrase-frequency/57583/2 "2016-08-09T21:12:12Z")

</div>

Do you always need to sort by phrase freq? If yes then I think you could just use a regular phrase query on a field that has norms disabled.

---

<div class="post-metadata">

### Author: ![viktorm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/viktorm/32/11279_2.png) [@viktorm](https://discuss.elastic.co/u/viktorm)
#### Post date: [August 9, 2016, 9:25pm UTC](https://discuss.elastic.co/t/filter-by-match-phrase-score-by-phrase-frequency/57583/3 "2016-08-09T21:25:36Z")

</div>

jpountz, all the time. Hence why I use similarity provider that returns 1 as IDF.

---

<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 5, 2017, 10:28pm UTC](https://discuss.elastic.co/t/filter-by-match-phrase-score-by-phrase-frequency/57583/4 "2017-07-05T22:28:59Z")

</div>


