# Scoring based on the number of matches in the field

**URL:** <https://discuss.elastic.co/t/scoring-based-on-the-number-of-matches-in-the-field/23219>\
**Category:** Elasticsearch\
**Created:** [April 13, 2015, 11:30pm UTC](https://discuss.elastic.co/t/scoring-based-on-the-number-of-matches-in-the-field/23219 "2015-04-13T23:30:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andre\_Dantas\_Rocha](https://avatars.discourse-cdn.com/v4/letter/a/3be4f8/32.png) [@Andre\_Dantas\_Rocha](https://discuss.elastic.co/u/Andre_Dantas_Rocha)\
**Post date:** [April 13, 2015, 11:30pm UTC](https://discuss.elastic.co/t/scoring-based-on-the-number-of-matches-in-the-field/23219/1 "2015-04-13T23:30:48Z")

</div>

Hi there,

I have the following query:

"query": {  
"multi\_match": {  
"operator": "and",  
"type": "cross\_fields",  
"query": "john smith",  
"fields": ["name", "address"]  
}  
}

That will match these documents:

Name: James _Smith_  
Address: 325 _John_ Street

Name: _John Smith_ Junior  
Address: 100 Baryl Street

Is there a way to give the last document a higher score since the terms  
"john" "smith" have two matches on the same field?

Notice that behavior is a little bit different from the one using  
match\_phrase with slop because the query can still match terms in any of  
the fields but score higher when there are more matches on the same field.

Thanks,

Andre

--  
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/cc76f51b-3721-4978-a3ed-e59ff4c8f138%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/cc76f51b-3721-4978-a3ed-e59ff4c8f138%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![softwaredoug](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/softwaredoug/32/22681_2.png) [@softwaredoug](https://discuss.elastic.co/u/softwaredoug)\
**Post date:** [April 14, 2015, 1:30am UTC](https://discuss.elastic.co/t/scoring-based-on-the-number-of-matches-in-the-field/23219/2 "2015-04-14T01:30:26Z")

</div>

First, note that in Lucene's default similarity there already are two  
biases towards matches with fewer fields. Try to take advantage of those  
before going on a boosting expedition

1. Each term tends to get converted into a boolean SHOULD clause. Every  
SHOULD clause match gets added to the score. So the fewer matches, the  
lower the score.

2. For an even stronger bias, Lucene adds **coord** or the coordinating  
factor. If only 1 out of 3 search terms match the field being searched, a  
multiple of 1/3 is applied thus punishing the score. So matches where more  
terms match should have a much higher chance of winning.

If you want to know more, read Lucene's javadocs on similarity:  
[https://lucene.apache.org/core/5\_0\_0/core/org/apache/lucene/search/similarities/TFIDFSimilarity.html](https://lucene.apache.org/core/5_0_0/core/org/apache/lucene/search/similarities/TFIDFSimilarity.html)

Huh you're thinking, why doesn't my scenario just work then. What you're  
doing is _cross\_field_ search. Cross field search is something new to  
Elasticsearch whereby both fields are blended together and treated like a  
single field. So the biasing above applies to the two fields together. If  
you want to know more about cross-field search -- here's an article I  
recently wrote

> **[Elasticsearch Cross Field Search Is A Lie - OpenSource Connections](https://opensourceconnections.com/blog/2015/03/19/elasticsearch-cross-field-search-is-a-lie/)**
>
> At OpenSource Connections, We Do What We Must, Because We Can In Elasticsearch, searching across multiple fields can be confusing to beginners. This is a tough first step in...

If you want to actually have a bias towards a field with more matches, I'd  
recommend best\_field or most\_fields search. They will take both search  
terms to each field first, performing different searches in each field.  
Then they will be combined (either by adding or taking the max score).

Untill I finish the related chapter in the search relevance book I'm  
writing \<shameless plug :-p [Relevant Search](http://manning.com/turnbull)\> the best place to  
read about these topics are the docs or the online guide. In particular,  
this appears relevant  
[Multifield Search | Elasticsearch: The Definitive Guide [master] | Elastic](http://www.elastic.co/guide/en/elasticsearch/guide/master/multi-field-search.html)

Hope that helps

On Mon, Apr 13, 2015 at 7:30 PM, Andre Dantas Rocha \<  
[andre.dantas.rocha@gmail.com](mailto:andre.dantas.rocha@gmail.com)\> wrote:

> Hi there,
> 
> I have the following query:
> 
> "query": {  
> "multi\_match": {  
> "operator": "and",  
> "type": "cross\_fields",  
> "query": "john smith",  
> "fields": ["name", "address"]  
> }  
> }
> 
> That will match these documents:
> 
> Name: James _Smith_  
> Address: 325 _John_ Street
> 
> Name: _John Smith_ Junior  
> Address: 100 Baryl Street
> 
> Is there a way to give the last document a higher score since the terms  
> "john" "smith" have two matches on the same field?
> 
> Notice that behavior is a little bit different from the one using  
> match\_phrase with slop because the query can still match terms in any of  
> the fields but score higher when there are more matches on the same field.
> 
> Thanks,
> 
> Andre
> 
> --  
> 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/cc76f51b-3721-4978-a3ed-e59ff4c8f138%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/cc76f51b-3721-4978-a3ed-e59ff4c8f138%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/cc76f51b-3721-4978-a3ed-e59ff4c8f138%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/cc76f51b-3721-4978-a3ed-e59ff4c8f138%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
\*Doug Turnbull \*\*| \*Search Relevance Consultant | OpenSource Connections,  
LLC | 240.476.9983 | [http://www.opensourceconnections.com](http://www.opensourceconnections.com)  
Author: Taming Search [http://manning.com/turnbull](http://manning.com/turnbull) from Manning  
Publications  
This e-mail and all contents, including attachments, is considered to be  
Company Confidential unless explicitly stated otherwise, regardless  
of whether attachments are marked as such.

--  
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/CALG6HL-BjkkULxXKH4WnbMnUBJF2TowjTe%2B51cHaJHE%2B2GBLcw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALG6HL-BjkkULxXKH4WnbMnUBJF2TowjTe%2B51cHaJHE%2B2GBLcw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![softwaredoug](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/softwaredoug/32/22681_2.png) [@softwaredoug](https://discuss.elastic.co/u/softwaredoug)\
**Post date:** [April 14, 2015, 2:21am UTC](https://discuss.elastic.co/t/scoring-based-on-the-number-of-matches-in-the-field/23219/3 "2015-04-14T02:21:22Z")

</div>

Sorry for the confusing typo -- "towards matches with fewer _fields"._ fields  
should be search _terms_

On Mon, Apr 13, 2015 at 9:30 PM, Doug Turnbull \<  
[dturnbull@opensourceconnections.com](mailto:dturnbull@opensourceconnections.com)\> wrote:

> First, note that in Lucene's default similarity there already are two  
> biases towards matches with fewer fields. Try to take advantage of those  
> before going on a boosting expedition
> 
> 1. Each term tends to get converted into a boolean SHOULD clause. Every  
> SHOULD clause match gets added to the score. So the fewer matches, the  
> lower the score.
> 
> 2. For an even stronger bias, Lucene adds **coord** or the coordinating  
> factor. If only 1 out of 3 search terms match the field being searched, a  
> multiple of 1/3 is applied thus punishing the score. So matches where more  
> terms match should have a much higher chance of winning.
> 
> If you want to know more, read Lucene's javadocs on similarity:  
> [TFIDFSimilarity (Lucene 5.0.0 API)](https://lucene.apache.org/core/5_0_0/core/org/apache/lucene/search/similarities/TFIDFSimilarity.html)
> 
> Huh you're thinking, why doesn't my scenario just work then. What you're  
> doing is _cross\_field_ search. Cross field search is something new to  
> Elasticsearch whereby both fields are blended together and treated like a  
> single field. So the biasing above applies to the two fields together. If  
> you want to know more about cross-field search -- here's an article I  
> recently wrote  
> [Elasticsearch Cross Field Search Is A Lie - OpenSource Connections](http://opensourceconnections.com/blog/2015/03/19/elasticsearch-cross-field-search-is-a-lie/)
> 
> If you want to actually have a bias towards a field with more matches, I'd  
> recommend best\_field or most\_fields search. They will take both search  
> terms to each field first, performing different searches in each field.  
> Then they will be combined (either by adding or taking the max score).
> 
> Untill I finish the related chapter in the search relevance book I'm  
> writing \<shameless plug :-p [Relevant Search](http://manning.com/turnbull)\> the best place  
> to read about these topics are the docs or the online guide. In particular,  
> this appears relevant
> 
> [Multifield Search | Elasticsearch: The Definitive Guide [master] | Elastic](http://www.elastic.co/guide/en/elasticsearch/guide/master/multi-field-search.html)
> 
> Hope that helps
> 
> On Mon, Apr 13, 2015 at 7:30 PM, Andre Dantas Rocha \<  
> [andre.dantas.rocha@gmail.com](mailto:andre.dantas.rocha@gmail.com)\> wrote:
> 
> > Hi there,
> > 
> > I have the following query:
> > 
> > "query": {  
> > "multi\_match": {  
> > "operator": "and",  
> > "type": "cross\_fields",  
> > "query": "john smith",  
> > "fields": ["name", "address"]  
> > }  
> > }
> > 
> > That will match these documents:
> > 
> > Name: James _Smith_  
> > Address: 325 _John_ Street
> > 
> > Name: _John Smith_ Junior  
> > Address: 100 Baryl Street
> > 
> > Is there a way to give the last document a higher score since the terms  
> > "john" "smith" have two matches on the same field?
> > 
> > Notice that behavior is a little bit different from the one using  
> > match\_phrase with slop because the query can still match terms in any of  
> > the fields but score higher when there are more matches on the same field.
> > 
> > Thanks,
> > 
> > Andre
> > 
> > --  
> > 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/cc76f51b-3721-4978-a3ed-e59ff4c8f138%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/cc76f51b-3721-4978-a3ed-e59ff4c8f138%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/cc76f51b-3721-4978-a3ed-e59ff4c8f138%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/cc76f51b-3721-4978-a3ed-e59ff4c8f138%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> \*Doug Turnbull \*\*| \*Search Relevance Consultant | OpenSource Connections,  
> LLC | 240.476.9983 | [http://www.opensourceconnections.com](http://www.opensourceconnections.com)  
> Author: Taming Search [http://manning.com/turnbull](http://manning.com/turnbull) from Manning  
> Publications  
> This e-mail and all contents, including attachments, is considered to be  
> Company Confidential unless explicitly stated otherwise, regardless  
> of whether attachments are marked as such.

--  
\*Doug Turnbull \*\*| \*Search Relevance Consultant | OpenSource Connections,  
LLC | 240.476.9983 | [http://www.opensourceconnections.com](http://www.opensourceconnections.com)  
Author: Taming Search [http://manning.com/turnbull](http://manning.com/turnbull) from Manning  
Publications  
This e-mail and all contents, including attachments, is considered to be  
Company Confidential unless explicitly stated otherwise, regardless  
of whether attachments are marked as such.

--  
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/CALG6HL9dr-At%2BxtWqsT6%3D%2BGehKEYsZsp2rvxp%3D9KFqPFbgiUjA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALG6HL9dr-At%2BxtWqsT6%3D%2BGehKEYsZsp2rvxp%3D9KFqPFbgiUjA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Andre\_Dantas\_Rocha](https://avatars.discourse-cdn.com/v4/letter/a/3be4f8/32.png) [@Andre\_Dantas\_Rocha](https://discuss.elastic.co/u/Andre_Dantas_Rocha)\
**Post date:** [April 14, 2015, 4:22am UTC](https://discuss.elastic.co/t/scoring-based-on-the-number-of-matches-in-the-field/23219/4 "2015-04-14T04:22:34Z")

</div>

Hi Doug,

Thank you for your quick response and comprehensive explanation. It does  
make sense.

We are using cross\_fields (with the "and" operator) because we want to make  
sure that the documents returned contain _all_ the search terms somewhere.

For example, the search for "100 john smith" would return only one  
document. ("john smith" matches the name and "100" matches the address")

We expect no results for "200 john smith" as 200 appears nowhere.

But if we search for "john smith" we should get both documents back and the  
document with "john smith" should be the first one is the list (since terms  
"john" "smith" matches on the same field).

Is there possible to accomplish this with best\_fields or most\_fields?

Thanks again,

Andre

On Tuesday, April 14, 2015 at 12:21:33 PM UTC+10, Doug Turnbull wrote:

> Sorry for the confusing typo -- "towards matches with fewer _fields"._ fields  
> should be search _terms_
> 
> On Mon, Apr 13, 2015 at 9:30 PM, Doug Turnbull \<  
> [dtur...@opensourceconnections.com](mailto:dtur...@opensourceconnections.com) \<javascript:\>\> wrote:
> 
> > First, note that in Lucene's default similarity there already are two  
> > biases towards matches with fewer fields. Try to take advantage of those  
> > before going on a boosting expedition
> > 
> > 1. Each term tends to get converted into a boolean SHOULD clause. Every  
> > SHOULD clause match gets added to the score. So the fewer matches, the  
> > lower the score.
> > 
> > 2. For an even stronger bias, Lucene adds **coord** or the coordinating  
> > factor. If only 1 out of 3 search terms match the field being searched, a  
> > multiple of 1/3 is applied thus punishing the score. So matches where more  
> > terms match should have a much higher chance of winning.
> > 
> > If you want to know more, read Lucene's javadocs on similarity:  
> > [TFIDFSimilarity (Lucene 5.0.0 API)](https://lucene.apache.org/core/5_0_0/core/org/apache/lucene/search/similarities/TFIDFSimilarity.html)
> > 
> > Huh you're thinking, why doesn't my scenario just work then. What you're  
> > doing is _cross\_field_ search. Cross field search is something new to  
> > Elasticsearch whereby both fields are blended together and treated like a  
> > single field. So the biasing above applies to the two fields together. If  
> > you want to know more about cross-field search -- here's an article I  
> > recently wrote  
> > [Elasticsearch Cross Field Search Is A Lie - OpenSource Connections](http://opensourceconnections.com/blog/2015/03/19/elasticsearch-cross-field-search-is-a-lie/)
> > 
> > If you want to actually have a bias towards a field with more matches,  
> > I'd recommend best\_field or most\_fields search. They will take both search  
> > terms to each field first, performing different searches in each field.  
> > Then they will be combined (either by adding or taking the max score).
> > 
> > Untill I finish the related chapter in the search relevance book I'm  
> > writing \<shameless plug :-p [Relevant Search](http://manning.com/turnbull)\> the best place  
> > to read about these topics are the docs or the online guide. In particular,  
> > this appears relevant
> > 
> > [Multifield Search | Elasticsearch: The Definitive Guide [master] | Elastic](http://www.elastic.co/guide/en/elasticsearch/guide/master/multi-field-search.html)
> > 
> > Hope that helps
> > 
> > On Mon, Apr 13, 2015 at 7:30 PM, Andre Dantas Rocha \<  
> > [andre.dan...@gmail.com](mailto:andre.dan...@gmail.com) \<javascript:\>\> wrote:
> > 
> > > Hi there,
> > > 
> > > I have the following query:
> > > 
> > > "query": {  
> > > "multi\_match": {  
> > > "operator": "and",  
> > > "type": "cross\_fields",  
> > > "query": "john smith",  
> > > "fields": ["name", "address"]  
> > > }  
> > > }
> > > 
> > > That will match these documents:
> > > 
> > > Name: James _Smith_  
> > > Address: 325 _John_ Street
> > > 
> > > Name: _John Smith_ Junior  
> > > Address: 100 Baryl Street
> > > 
> > > Is there a way to give the last document a higher score since the terms  
> > > "john" "smith" have two matches on the same field?
> > > 
> > > Notice that behavior is a little bit different from the one using  
> > > match\_phrase with slop because the query can still match terms in any of  
> > > the fields but score higher when there are more matches on the same field.
> > > 
> > > Thanks,
> > > 
> > > Andre
> > > 
> > > --  
> > > 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/cc76f51b-3721-4978-a3ed-e59ff4c8f138%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/cc76f51b-3721-4978-a3ed-e59ff4c8f138%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/cc76f51b-3721-4978-a3ed-e59ff4c8f138%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/cc76f51b-3721-4978-a3ed-e59ff4c8f138%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .  
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > \*Doug Turnbull \*\*| \*Search Relevance Consultant | OpenSource  
> > Connections, LLC | 240.476.9983 | [http://www.opensourceconnections.com](http://www.opensourceconnections.com)  
> > Author: Taming Search [http://manning.com/turnbull](http://manning.com/turnbull) from Manning  
> > Publications  
> > This e-mail and all contents, including attachments, is considered to be  
> > Company Confidential unless explicitly stated otherwise, regardless  
> > of whether attachments are marked as such.
> 
> --  
> \*Doug Turnbull \*\*| \*Search Relevance Consultant | OpenSource Connections,  
> LLC | 240.476.9983 | [http://www.opensourceconnections.com](http://www.opensourceconnections.com)  
> Author: Taming Search [http://manning.com/turnbull](http://manning.com/turnbull) from Manning  
> Publications  
> This e-mail and all contents, including attachments, is considered to be  
> Company Confidential unless explicitly stated otherwise, regardless  
> of whether attachments are marked as such.

--  
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/49b56ab9-bdd0-4d7d-b63f-963d05b70744%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/49b56ab9-bdd0-4d7d-b63f-963d05b70744%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Andre\_Dantas\_Rocha](https://avatars.discourse-cdn.com/v4/letter/a/3be4f8/32.png) [@Andre\_Dantas\_Rocha](https://discuss.elastic.co/u/Andre_Dantas_Rocha)\
**Post date:** [April 14, 2015, 4:24am UTC](https://discuss.elastic.co/t/scoring-based-on-the-number-of-matches-in-the-field/23219/5 "2015-04-14T04:24:21Z")

</div>

Hi Doug,

Thank you for your quick response and comprehensive explanation. It does  
make sense.

We are using cross\_fields (with the "and" operator) because we want to make  
sure that the documents returned contain _all_ the search terms somewhere.

For example, the search for "100 john smith" would return only one  
document. ("john smith" matches the name and "100" matches the address")

We expect no results for "200 john smith" as 200 appears nowhere.

But if we search for "john smith" we should get both documents back and the  
document with "john smith" should be the first one is the list (since terms  
"john" "smith" matches on the same field).

Is there possible to accomplish this with best\_fields or most\_fields?

Thanks again,

Andre

--  
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/b9f21865-c060-434e-b456-80a230ac6439%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b9f21865-c060-434e-b456-80a230ac6439%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![softwaredoug](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/softwaredoug/32/22681_2.png) [@softwaredoug](https://discuss.elastic.co/u/softwaredoug)\
**Post date:** [April 14, 2015, 6:56pm UTC](https://discuss.elastic.co/t/scoring-based-on-the-number-of-matches-in-the-field/23219/6 "2015-04-14T18:56:07Z")

</div>

If you want this to be a mininum you could

- Use your cross fields query as a filter  
[http://www.elastic.co/guide/en/elasticsearch/reference/1.5/query-dsl-filters.html](http://www.elastic.co/guide/en/elasticsearch/reference/1.5/query-dsl-filters.html).  
Specifically, a query filter:  
[Query Filter | Elasticsearch Guide [1.5] | Elastic](http://www.elastic.co/guide/en/elasticsearch/reference/1.5/query-dsl-query-filter.html)
- Use a most or best fields as your main search query

This would eliminate any search results without a match somewhere, cutting  
off the long tail as you need to, but score using most fields.

Does that make sense?

On Tue, Apr 14, 2015 at 12:24 AM, Andre Dantas Rocha \<  
[andre.dantas.rocha@gmail.com](mailto:andre.dantas.rocha@gmail.com)\> wrote:

> Hi Doug,
> 
> Thank you for your quick response and comprehensive explanation. It does  
> make sense.
> 
> We are using cross\_fields (with the "and" operator) because we want to  
> make sure that the documents returned contain _all_ the search terms  
> somewhere.
> 
> For example, the search for "100 john smith" would return only one  
> document. ("john smith" matches the name and "100" matches the address")
> 
> We expect no results for "200 john smith" as 200 appears nowhere.
> 
> But if we search for "john smith" we should get both documents back and  
> the document with "john smith" should be the first one is the list  
> (since terms "john" "smith" matches on the same field).
> 
> Is there possible to accomplish this with best\_fields or most\_fields?
> 
> Thanks again,
> 
> Andre
> 
> --  
> 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/b9f21865-c060-434e-b456-80a230ac6439%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b9f21865-c060-434e-b456-80a230ac6439%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/b9f21865-c060-434e-b456-80a230ac6439%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/b9f21865-c060-434e-b456-80a230ac6439%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
\*Doug Turnbull \*\*| \*Search Relevance Consultant | OpenSource Connections,  
LLC | 240.476.9983 | [http://www.opensourceconnections.com](http://www.opensourceconnections.com)  
Author: Taming Search [http://manning.com/turnbull](http://manning.com/turnbull) from Manning  
Publications  
This e-mail and all contents, including attachments, is considered to be  
Company Confidential unless explicitly stated otherwise, regardless  
of whether attachments are marked as such.

--  
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/CALG6HL-otHfwDshPnv5e8Ys4gm8wnOdZzkSzzW8Fs9YEYodrUg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALG6HL-otHfwDshPnv5e8Ys4gm8wnOdZzkSzzW8Fs9YEYodrUg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Andre\_Dantas\_Rocha](https://avatars.discourse-cdn.com/v4/letter/a/3be4f8/32.png) [@Andre\_Dantas\_Rocha](https://discuss.elastic.co/u/Andre_Dantas_Rocha)\
**Post date:** [April 14, 2015, 11:58pm UTC](https://discuss.elastic.co/t/scoring-based-on-the-number-of-matches-in-the-field/23219/7 "2015-04-14T23:58:23Z")

</div>

Hi Doug,

Yes. it does make sense. I'll try to rewrite it and get back to you.

Thank you again for your help,  
Andre

--  
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/3e69b3de-30f1-4952-845a-6d75eff846f6%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3e69b3de-30f1-4952-845a-6d75eff846f6%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Andre\_Dantas\_Rocha](https://avatars.discourse-cdn.com/v4/letter/a/3be4f8/32.png) [@Andre\_Dantas\_Rocha](https://discuss.elastic.co/u/Andre_Dantas_Rocha)\
**Post date:** [April 16, 2015, 7:39pm UTC](https://discuss.elastic.co/t/scoring-based-on-the-number-of-matches-in-the-field/23219/8 "2015-04-16T19:39:57Z")

</div>

Hi Doug,

Your suggestion worked perfectly!

Thank very much.

Andre

--  
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/8c1b36c1-d0fb-45e7-8e3b-2b4934e02c7f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8c1b36c1-d0fb-45e7-8e3b-2b4934e02c7f%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, 12:19am UTC](https://discuss.elastic.co/t/scoring-based-on-the-number-of-matches-in-the-field/23219/9 "2017-07-06T00:19:13Z")

</div>


