# Boosting a list of field for queries

**URL:** <https://discuss.elastic.co/t/boosting-a-list-of-field-for-queries/19692>\
**Category:** Elasticsearch\
**Created:** [September 9, 2014, 5:50pm UTC](https://discuss.elastic.co/t/boosting-a-list-of-field-for-queries/19692 "2014-09-09T17:50:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![asthanaamish](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@asthanaamish](https://discuss.elastic.co/u/asthanaamish)\
**Post date:** [September 9, 2014, 5:50pm UTC](https://discuss.elastic.co/t/boosting-a-list-of-field-for-queries/19692/1 "2014-09-09T17:50:21Z")

</div>

Hi Folks  
We have a bunch of fields for a document.  
Lets call them "field1",'field2"....., "FIELD1","FIELD2"......

When we search for a particular text we want to see those records first  
which has that text in "FIELD1"..."FIELDn" before records from "field1",  
"field2" etc.

Now the complications :  
a) We have lots of field. Doing internal testing we found that if we copy  
the fields to a common field(using "copy\_to" something akin to \_all field)  
and do search only that field then the search is much faster then doing a  
multi match query on list of fields. Not found any document on this, but  
this seem to be the case in all our internal testing.  
b) We have our own analyzer for different copy to field. So lets say I have  
"my\_own\_analyzed\_all\_field1" on which I am searching. All values from  
"field1"..... "FIELDn" is copied here.  
c) The "boost" parameter for field as far I see work for field type( As far  
as I see its only deprecated for document ). However this only works if the  
result is going to "\_all' field. It does not seem to be boosting the field  
getting copied to "my\_own\_analyzed\_all\_field1".

So the question is can it be done here? Or do we have to do multi match  
query with each field boosted by certain factor.

--  
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/826be7eb-766a-400c-9198-c47771a385c7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/826be7eb-766a-400c-9198-c47771a385c7%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![asthanaamish](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@asthanaamish](https://discuss.elastic.co/u/asthanaamish)\
**Post date:** [September 10, 2014, 5:01am UTC](https://discuss.elastic.co/t/boosting-a-list-of-field-for-queries/19692/2 "2014-09-10T05:01:19Z")

</div>

Hi Folks  
I have created test data like this in Sense.  
PUT /myccindexallanalyzed/testobject/\_bulk  
{"index":{"\_id":1}}  
{"name":"do not","description":"single test word"}  
{"index":{"\_id":2}}  
{"name":"single test word","description":"do not"}

I am trying to search for "sin\* test" and want the document which has this  
phrase in Name field to be first.  
I do get the document but the one in the description field has higher  
score. What am I doing wrong here?  
Here is the query :

GET myccindexallanalyzed/testobject/\_search?explain  
{  
"query": {  
"bool": {  
"should" : [  
{  
"span\_near":  
{"clauses":  
[

{"span\_multi":{"match":{"wildcard":{"description":{"wildcard":"sin\*","boost":1.0}}}}}  
,{"span\_multi":{"match":{"wildcard":{"description":{"wildcard":"test","boost":1.0}}}}}  
]  
,"slop":0 ,"in\_order":true,"collect\_payloads":false  
}  
},  
{  
"span\_near":  
{"clauses":  
[

{"span\_multi":{"match":{"wildcard":{"name":{"wildcard":"sin\*","boost":2.0}}}}}  
,{"span\_multi":{"match":{"wildcard":{"name":{"wildcard":"test","boost":2.0}}}}}  
]  
,"slop":0 ,"in\_order":true,"collect\_payloads":false  
}  
}  
]  
,"minimum\_should\_match" : 1  
}  
}  
}

On Tuesday, September 9, 2014 10:50:21 AM UTC-7, Amish Asthana wrote:

> Hi Folks  
> We have a bunch of fields for a document.  
> Lets call them "field1",'field2"....., "FIELD1","FIELD2"......
> 
> When we search for a particular text we want to see those records first  
> which has that text in "FIELD1"..."FIELDn" before records from "field1",  
> "field2" etc.
> 
> Now the complications :  
> a) We have lots of field. Doing internal testing we found that if we copy  
> the fields to a common field(using "copy\_to" something akin to \_all field)  
> and do search only that field then the search is much faster then doing a  
> multi match query on list of fields. Not found any document on this, but  
> this seem to be the case in all our internal testing.  
> b) We have our own analyzer for different copy to field. So lets say I  
> have "my\_own\_analyzed\_all\_field1" on which I am searching. All values from  
> "field1"..... "FIELDn" is copied here.  
> c) The "boost" parameter for field as far I see work for field type( As  
> far as I see its only deprecated for document ). However this only works if  
> the result is going to "\_all' field. It does not seem to be boosting the  
> field getting copied to "my\_own\_analyzed\_all\_field1".
> 
> So the question is can it be done here? Or do we have to do multi match  
> query with each field boosted by certain factor.

--  
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/8eac1aa8-8b06-44c3-b4d0-20965160e771%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8eac1aa8-8b06-44c3-b4d0-20965160e771%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![asthanaamish](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@asthanaamish](https://discuss.elastic.co/u/asthanaamish)\
**Post date:** [September 22, 2014, 9:19pm UTC](https://discuss.elastic.co/t/boosting-a-list-of-field-for-queries/19692/3 "2014-09-22T21:19:46Z")

</div>

Not seen any reply.  
Can anyone guide us.  
Let me ask in another way :  
a) Lets say i have document with 10 fields.  
Assume that there is no boosting etc. required for any field. Now lets say  
we have "\_all" fields encompassing all these fields.  
Question : Is the query on just "\_all" field faster then field by field  
query?  
If so by what factor? ( To me logically it should tokens in "\_all" field  
should be less than equal to summation of all fields and thus time should  
be less than field by field, approaching \_all case if all are distinct  
token.)

b) Then the second part of question is how to boost a field; if its getting  
copied to a copy to field.  
regards and thanks  
amish

On Tuesday, September 9, 2014 10:50:21 AM UTC-7, Amish Asthana wrote:

> Hi Folks  
> We have a bunch of fields for a document.  
> Lets call them "field1",'field2"....., "FIELD1","FIELD2"......
> 
> When we search for a particular text we want to see those records first  
> which has that text in "FIELD1"..."FIELDn" before records from "field1",  
> "field2" etc.
> 
> Now the complications :  
> a) We have lots of field. Doing internal testing we found that if we copy  
> the fields to a common field(using "copy\_to" something akin to \_all field)  
> and do search only that field then the search is much faster then doing a  
> multi match query on list of fields. Not found any document on this, but  
> this seem to be the case in all our internal testing.  
> b) We have our own analyzer for different copy to field. So lets say I  
> have "my\_own\_analyzed\_all\_field1" on which I am searching. All values from  
> "field1"..... "FIELDn" is copied here.  
> c) The "boost" parameter for field as far I see work for field type( As  
> far as I see its only deprecated for document ). However this only works if  
> the result is going to "\_all' field. It does not seem to be boosting the  
> field getting copied to "my\_own\_analyzed\_all\_field1".
> 
> So the question is can it be done here? Or do we have to do multi match  
> query with each field boosted by certain factor.

--  
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/cf0b5392-e463-4f79-8218-ebff8167f7b6%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/cf0b5392-e463-4f79-8218-ebff8167f7b6%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:00am UTC](https://discuss.elastic.co/t/boosting-a-list-of-field-for-queries/19692/4 "2017-07-06T01:00:32Z")

</div>


