# Document's Field level boosting

**URL:** <https://discuss.elastic.co/t/documents-field-level-boosting/4373>\
**Category:** Elasticsearch\
**Created:** [May 9, 2011, 4:44pm UTC](https://discuss.elastic.co/t/documents-field-level-boosting/4373 "2011-05-09T16:44:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![freddj](https://avatars.discourse-cdn.com/v4/letter/f/e8c25b/32.png) [@freddj](https://discuss.elastic.co/u/freddj)\
**Post date:** [May 9, 2011, 4:44pm UTC](https://discuss.elastic.co/t/documents-field-level-boosting/4373/1 "2011-05-09T16:44:18Z")

</div>

Hi,

From an irc discussion, I understood (sorry if I'm wrong) that  
Document's Field level boosting (as described there  
[http://lucene.apache.org/java/3\_0\_0/scoring.html](http://lucene.apache.org/java/3_0_0/scoring.html) and  
[http://lucene.apache.org/java/3\_0\_0/api/core/org/apache/lucene/document/Fieldable.html#setBoost(float)](http://lucene.apache.org/java/3_0_0/api/core/org/apache/lucene/document/Fieldable.html#setBoost%28float%29)  
) is NOT available currently. The problem seems to be that it's not  
easy to have a nice API over json.  
Solr does not have this issue since their XML api permits to decorate  
any field with arbitrary meta data. So, to set a boost on a specific  
field, on a specific document, they just do:

```
<field name="office" boost="2.0">Bridgewater</field>

```

(from [http://wiki.apache.org/solr/UpdateXmlMessages](http://wiki.apache.org/solr/UpdateXmlMessages))

We are in the middle of switching from solr to elasticsearch but we  
rely on this missing feature. It would help a lot to have it and it  
might prevent the switch altogether.

Apart from the API issue, the feature does not look difficult to  
implement.  
Can we start discussing API there?

Here is my 2 cents proposal:  
In the mapping, specify that a field is of string type.  
{  
"office" : {  
"type: "string"  
}  
}

And to specify the field boost in a document, do it this way:

{  
"office" : {  
"\_value": "Bridgewater",  
"\_boost": 2.0  
}  
}

What do you think of this?

Thanks

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 9, 2011, 4:49pm UTC](https://discuss.elastic.co/t/documents-field-level-boosting/4373/2 "2011-05-09T16:49:20Z")

</div>

Sounds like a good format, but it will only work if the object/field was explicitly mapped as a string, otherwise, boost will be indexed as a field. Care to open an issue for this?  
On Monday, May 9, 2011 at 7:44 PM, freddj wrote:

> Hi,
> 
> From an irc discussion, I understood (sorry if I'm wrong) that  
> Document's Field level boosting (as described there  
> [Apache Lucene - Scoring](http://lucene.apache.org/java/3_0_0/scoring.html) and  
> [Fieldable (Lucene 3.0.3 API)](http://lucene.apache.org/java/3_0_0/api/core/org/apache/lucene/document/Fieldable.html#setBoost%28float%29)  
> ) is NOT available currently. The problem seems to be that it's not  
> easy to have a nice API over json.  
> Solr does not have this issue since their XML api permits to decorate  
> any field with arbitrary meta data. So, to set a boost on a specific  
> field, on a specific document, they just do:
> 
> Bridgewater  
> (from [UpdateXmlMessages - Solr - Apache Software Foundation](http://wiki.apache.org/solr/UpdateXmlMessages))
> 
> We are in the middle of switching from solr to elasticsearch but we  
> rely on this missing feature. It would help a lot to have it and it  
> might prevent the switch altogether.
> 
> Apart from the API issue, the feature does not look difficult to  
> implement.  
> Can we start discussing API there?
> 
> Here is my 2 cents proposal:  
> In the mapping, specify that a field is of string type.  
> {  
> "office" : {  
> "type: "string"  
> }  
> }
> 
> And to specify the field boost in a document, do it this way:
> 
> {  
> "office" : {  
> "\_value": "Bridgewater",  
> "\_boost": 2.0  
> }  
> }
> 
> What do you think of this?
> 
> Thanks

---

<div class="post-metadata">

**Author:** ![freddj](https://avatars.discourse-cdn.com/v4/letter/f/e8c25b/32.png) [@freddj](https://discuss.elastic.co/u/freddj)\
**Post date:** [May 9, 2011, 8:08pm UTC](https://discuss.elastic.co/t/documents-field-level-boosting/4373/3 "2011-05-09T20:08:31Z")

</div>

sure, here it is:

> <https://github.com/elastic/elasticsearch/issues/920>

---

<div class="post-metadata">

**Author:** ![Michel\_Conrad](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michel\_Conrad](https://discuss.elastic.co/u/Michel_Conrad)\
**Post date:** [May 10, 2011, 1:16pm UTC](https://discuss.elastic.co/t/documents-field-level-boosting/4373/4 "2011-05-10T13:16:10Z")

</div>

Hi,

I was wondering if I could use field level boosts in order to  
implement different ranked results from search results.

If I have different criteria for ranking my documents at index time,  
my initial idea was to assign a field boost with the ranking  
information to different fields for the different ranking  
possibilities.  
At search time I would then have the possibility to select different  
boosts by selecting different fields to include in the query. Is this  
the right way to do it, and is it possibile to do it with  
elasticsearch  
at the moment?

Thanks,  
Michel

On Mon, May 9, 2011 at 10:08 PM, freddj [fastphilg@gmail.com](mailto:fastphilg@gmail.com) wrote:

> sure, here it is:  
> [Mapping: Document's Field level boosting · Issue #920 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/920)

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 10, 2011, 7:14pm UTC](https://discuss.elastic.co/t/documents-field-level-boosting/4373/5 "2011-05-10T19:14:31Z")

</div>

Yes, this is certainly possible with how elasticsearch works now, though, index time boosting will use less resources.  
On Tuesday, May 10, 2011 at 4:16 PM, Michel Conrad wrote:

> Hi,
> 
> I was wondering if I could use field level boosts in order to  
> implement different ranked results from search results.
> 
> If I have different criteria for ranking my documents at index time,  
> my initial idea was to assign a field boost with the ranking  
> information to different fields for the different ranking  
> possibilities.  
> At search time I would then have the possibility to select different  
> boosts by selecting different fields to include in the query. Is this  
> the right way to do it, and is it possibile to do it with  
> elasticsearch  
> at the moment?
> 
> Thanks,  
> Michel
> 
> On Mon, May 9, 2011 at 10:08 PM, freddj [fastphilg@gmail.com](mailto:fastphilg@gmail.com) wrote:
> 
> > sure, here it is:  
> > [Mapping: Document's Field level boosting · Issue #920 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/920)

---

<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, 4:06am UTC](https://discuss.elastic.co/t/documents-field-level-boosting/4373/6 "2017-07-06T04:06:33Z")

</div>


