# Copy\_to and boost factor

**URL:** <https://discuss.elastic.co/t/copy-to-and-boost-factor/21431>\
**Category:** Elasticsearch\
**Created:** [December 30, 2014, 8:36am UTC](https://discuss.elastic.co/t/copy-to-and-boost-factor/21431 "2014-12-30T08:36:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Preeti\_Jain](https://avatars.discourse-cdn.com/v4/letter/p/67e7ee/32.png) [@Preeti\_Jain](https://discuss.elastic.co/u/Preeti_Jain)\
**Post date:** [December 30, 2014, 8:36am UTC](https://discuss.elastic.co/t/copy-to-and-boost-factor/21431/1 "2014-12-30T08:36:34Z")

</div>

Hi,

Does the individual boost factor get honoured for fields getting copied  
into a custom \_all field via copy\_to option?  
I am facing issues with the behavior. Have a look at the example below

PUT localhost:9200/investigations/TestCustom/\_mapping  
{  
"TestCustom": {  
"properties": {  
"custom\_all":{  
"type": "string"  
},  
"name":{  
"type": "string",  
"copy\_to":"custom\_all",  
"boost":2.0  
},  
"surName":{  
"type": "string",  
"copy\_to":"custom\_all"  
},  
"dateRecorded":{  
"type": "date",  
"copy\_to":"custom\_all"  
},  
"Id":{  
"type": "long",  
"copy\_to":"custom\_all"  
}  
}  
}  
}

Fiels "name" has been given a boost factor of 2.0

I post 2 documents now

POST localhost:9200/investigations/TestCustom/5  
{  
"surName":"Preeti"  
}  
POST localhost:9200/investigations/TestCustom/6  
{  
"name":"Preeti"  
}

and then search the custom\_all field

GET localhost:9200/investigations/TestCustom/\_search  
{  
"query":{  
"query\_string": {  
"default\_field": "custom\_all",  
"query": "Preeti"  
}  
}  
}

I expected document with id 6 to be the top result but the results were

{  
"took": 40,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 2,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "investigations",  
"\_type": "TestCustom",  
"\_id": "5",  
"\_score": 1,  
"\_source": {  
"surName": "Preeti"  
}  
},  
{  
"\_index": "investigations",  
"\_type": "TestCustom",  
"\_id": "6",  
"\_score": 1,  
"\_source": {  
"name": "Preeti"  
}  
}  
]  
}  
}

Is this expected behavior?

--  
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/79af9adb-5dce-4a7a-897b-16cd962c8a40%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/79af9adb-5dce-4a7a-897b-16cd962c8a40%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [December 30, 2014, 9:13am UTC](https://discuss.elastic.co/t/copy-to-and-boost-factor/21431/2 "2014-12-30T09:13:11Z")

</div>

Boosting is not supported in copy\_to, see

> <https://github.com/elastic/elasticsearch/pull/4972>
>
> Currently, boosting on \`copy\_to\` is misleading and does not work as originally s…pecified in #4520. Instead of boosting just the terms from the origin field, it boosts the whole destination field. If two fields copy\_to a third field, one with a boost of 2 and another with a boost of 3, all the terms in the third field end up with a boost of 6. This was not the intention.
> 
> The alternative: to store the boost in a payload for every term, results in poor performance and inflexibility. Instead, users should either (1) query the common field AND the field that requires boosting, or (2) the multi\_match query will soon be able to perform term-centric cross-field matching that will allow per-field boosting at query time (coming in 1.1).

Alternative, as quoted from the commit message

"Instead, users should either (1) query the common field AND the field that  
requires boosting, or (2) the multi\_match query will soon be able to  
perform term-centric cross-field matching that will allow per-field  
boosting at query time (coming in 1.1)."

See my multi\_match gist for an example

> <https://gist.github.com/jprante/85126685973311603c8a>

Jörg

On Tue, Dec 30, 2014 at 9:36 AM, Preeti Jain [itspreeti@gmail.com](mailto:itspreeti@gmail.com) wrote:

> Hi,
> 
> Does the individual boost factor get honoured for fields getting copied  
> into a custom \_all field via copy\_to option?  
> I am facing issues with the behavior. Have a look at the example below
> 
> PUT localhost:9200/investigations/TestCustom/\_mapping  
> {  
> "TestCustom": {  
> "properties": {  
> "custom\_all":{  
> "type": "string"  
> },  
> "name":{  
> "type": "string",  
> "copy\_to":"custom\_all",  
> "boost":2.0  
> },  
> "surName":{  
> "type": "string",  
> "copy\_to":"custom\_all"  
> },  
> "dateRecorded":{  
> "type": "date",  
> "copy\_to":"custom\_all"  
> },  
> "Id":{  
> "type": "long",  
> "copy\_to":"custom\_all"  
> }  
> }  
> }  
> }
> 
> Fiels "name" has been given a boost factor of 2.0
> 
> I post 2 documents now
> 
> POST localhost:9200/investigations/TestCustom/5  
> {  
> "surName":"Preeti"  
> }  
> POST localhost:9200/investigations/TestCustom/6  
> {  
> "name":"Preeti"  
> }
> 
> and then search the custom\_all field
> 
> GET localhost:9200/investigations/TestCustom/\_search  
> {  
> "query":{  
> "query\_string": {  
> "default\_field": "custom\_all",  
> "query": "Preeti"  
> }  
> }  
> }
> 
> I expected document with id 6 to be the top result but the results were
> 
> {  
> "took": 40,  
> "timed\_out": false,  
> "\_shards": {  
> "total": 5,  
> "successful": 5,  
> "failed": 0  
> },  
> "hits": {  
> "total": 2,  
> "max\_score": 1,  
> "hits": [  
> {  
> "\_index": "investigations",  
> "\_type": "TestCustom",  
> "\_id": "5",  
> "\_score": 1,  
> "\_source": {  
> "surName": "Preeti"  
> }  
> },  
> {  
> "\_index": "investigations",  
> "\_type": "TestCustom",  
> "\_id": "6",  
> "\_score": 1,  
> "\_source": {  
> "name": "Preeti"  
> }  
> }  
> ]  
> }  
> }
> 
> Is this expected behavior?
> 
> --  
> 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/79af9adb-5dce-4a7a-897b-16cd962c8a40%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/79af9adb-5dce-4a7a-897b-16cd962c8a40%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/79af9adb-5dce-4a7a-897b-16cd962c8a40%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/79af9adb-5dce-4a7a-897b-16cd962c8a40%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFoMaubLqX%2BhODrq74mKtM33%2BAojT8NrDNO%2BpumtDHNCA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFoMaubLqX%2BhODrq74mKtM33%2BAojT8NrDNO%2BpumtDHNCA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Preeti\_Jain](https://avatars.discourse-cdn.com/v4/letter/p/67e7ee/32.png) [@Preeti\_Jain](https://discuss.elastic.co/u/Preeti_Jain)\
**Post date:** [December 30, 2014, 9:31am UTC](https://discuss.elastic.co/t/copy-to-and-boost-factor/21431/3 "2014-12-30T09:31:25Z")

</div>

Thanks Jörg.

On Tuesday, December 30, 2014 2:43:20 PM UTC+5:30, Jörg Prante wrote:

> Boosting is not supported in copy\_to, see
> 
> [Remove support for boost in copy\_to field by imotov · Pull Request #4972 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/4972)
> 
> Alternative, as quoted from the commit message
> 
> "Instead, users should either (1) query the common field AND the field  
> that requires boosting, or (2) the multi\_match query will soon be able to  
> perform term-centric cross-field matching that will allow per-field  
> boosting at query time (coming in 1.1)."
> 
> See my multi\_match gist for an example
> 
> [multi\_match and boost · GitHub](https://gist.github.com/jprante/85126685973311603c8a)
> 
> Jörg
> 
> On Tue, Dec 30, 2014 at 9:36 AM, Preeti Jain \<[itsp...@gmail.com](mailto:itsp...@gmail.com)  
> \<javascript:\>\> wrote:
> 
> > Hi,
> > 
> > Does the individual boost factor get honoured for fields getting copied  
> > into a custom \_all field via copy\_to option?  
> > I am facing issues with the behavior. Have a look at the example below
> > 
> > PUT localhost:9200/investigations/TestCustom/\_mapping  
> > {  
> > "TestCustom": {  
> > "properties": {  
> > "custom\_all":{  
> > "type": "string"  
> > },  
> > "name":{  
> > "type": "string",  
> > "copy\_to":"custom\_all",  
> > "boost":2.0  
> > },  
> > "surName":{  
> > "type": "string",  
> > "copy\_to":"custom\_all"  
> > },  
> > "dateRecorded":{  
> > "type": "date",  
> > "copy\_to":"custom\_all"  
> > },  
> > "Id":{  
> > "type": "long",  
> > "copy\_to":"custom\_all"  
> > }  
> > }  
> > }  
> > }
> > 
> > Fiels "name" has been given a boost factor of 2.0
> > 
> > I post 2 documents now
> > 
> > POST localhost:9200/investigations/TestCustom/5  
> > {  
> > "surName":"Preeti"  
> > }  
> > POST localhost:9200/investigations/TestCustom/6  
> > {  
> > "name":"Preeti"  
> > }
> > 
> > and then search the custom\_all field
> > 
> > GET localhost:9200/investigations/TestCustom/\_search  
> > {  
> > "query":{  
> > "query\_string": {  
> > "default\_field": "custom\_all",  
> > "query": "Preeti"  
> > }  
> > }  
> > }
> > 
> > I expected document with id 6 to be the top result but the results were
> > 
> > {  
> > "took": 40,  
> > "timed\_out": false,  
> > "\_shards": {  
> > "total": 5,  
> > "successful": 5,  
> > "failed": 0  
> > },  
> > "hits": {  
> > "total": 2,  
> > "max\_score": 1,  
> > "hits": [  
> > {  
> > "\_index": "investigations",  
> > "\_type": "TestCustom",  
> > "\_id": "5",  
> > "\_score": 1,  
> > "\_source": {  
> > "surName": "Preeti"  
> > }  
> > },  
> > {  
> > "\_index": "investigations",  
> > "\_type": "TestCustom",  
> > "\_id": "6",  
> > "\_score": 1,  
> > "\_source": {  
> > "name": "Preeti"  
> > }  
> > }  
> > ]  
> > }  
> > }
> > 
> > Is this expected behavior?
> > 
> > --  
> > 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/79af9adb-5dce-4a7a-897b-16cd962c8a40%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/79af9adb-5dce-4a7a-897b-16cd962c8a40%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/79af9adb-5dce-4a7a-897b-16cd962c8a40%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/79af9adb-5dce-4a7a-897b-16cd962c8a40%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/54ed8625-a8bc-4be4-b48a-18b364d51a66%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/54ed8625-a8bc-4be4-b48a-18b364d51a66%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:41am UTC](https://discuss.elastic.co/t/copy-to-and-boost-factor/21431/4 "2017-07-06T00:41:28Z")

</div>


