# About score of a document

**URL:** https://discuss.elastic.co/t/about-score-of-a-document/6125
**Category:** Elasticsearch
**Created:** [December 12, 2011, 8:51am UTC](https://discuss.elastic.co/t/about-score-of-a-document/6125 "2011-12-12T08:51:43Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![BARNEY](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@BARNEY](https://discuss.elastic.co/u/BARNEY)
#### Post date: [December 12, 2011, 8:51am UTC](https://discuss.elastic.co/t/about-score-of-a-document/6125/1 "2011-12-12T08:51:43Z")

</div>

How to increase the score for a particular record?

---

<div class="post-metadata">

### Author: ![Karussell1](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Karussell1](https://discuss.elastic.co/u/Karussell1)
#### Post date: [December 12, 2011, 9:20am UTC](https://discuss.elastic.co/t/about-score-of-a-document/6125/2 "2011-12-12T09:20:15Z")

</div>

boost it while indexing

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

or querying

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

etc

Peter.

On 12 Dez., 09:51, BARNEY [kalyanc...@gmail.com](mailto:kalyanc...@gmail.com) wrote:

> How to increase the score for a particular record?

---

<div class="post-metadata">

### Author: ![BARNEY](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@BARNEY](https://discuss.elastic.co/u/BARNEY)
#### Post date: [December 12, 2011, 1:57pm UTC](https://discuss.elastic.co/t/about-score-of-a-document/6125/3 "2011-12-12T13:57:17Z")

</div>

Thanks !!  
Do u have any examples to write java code for this?  
On Mon, Dec 12, 2011 at 2:50 PM, Karussell [tableyourtime@googlemail.com](mailto:tableyourtime@googlemail.com)wrote:

> boost it while indexing
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/boost-field.html)
> 
> or querying
> 
> [http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.html)  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/boosting-query.html)
> 
> etc
> 
> Peter.
> 
> On 12 Dez., 09:51, BARNEY [kalyanc...@gmail.com](mailto:kalyanc...@gmail.com) wrote:
> 
> > How to increase the score for a particular record?

---

<div class="post-metadata">

### Author: ![Karussell1](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Karussell1](https://discuss.elastic.co/u/Karussell1)
#### Post date: [December 12, 2011, 8:40pm UTC](https://discuss.elastic.co/t/about-score-of-a-document/6125/4 "2011-12-12T20:40:17Z")

</div>

On 12 Dez., 14:57, kalyan chowdary [kalyanc...@gmail.com](mailto:kalyanc...@gmail.com) wrote:

> Thanks !!  
> Do u have any examples to write java code for this?

for which concrete example?

QueryBuilders.customScoreQuery(QueryBuilders.matchAllQuery()).script("mybooster").lang("native").param("friends",  
friends)

QueryBuilders.boostingQuery().positive(QueryBuilders.fieldQuery("someField",  
12)).negative(QueryBuilders.termsQuery("names", "peter", "ron",  
"don"));

while indexing you'll need to set the \_boost:  
XContentBuilder b = JsonXContent.contentBuilder().startObject();  
b.field("url", url);  
b.field("\_boost", someCustomScore);  
...  
b.endObject();  
addToYourBulkIndexing(b);

Peter.

---

<div class="post-metadata">

### Author: ![BARNEY](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@BARNEY](https://discuss.elastic.co/u/BARNEY)
#### Post date: [December 13, 2011, 7:12am UTC](https://discuss.elastic.co/t/about-score-of-a-document/6125/5 "2011-12-13T07:12:54Z")

</div>

Intially I want to start with curl commands like below:

While idexing I set the boost here:  
curl -XPOST localhost:9200/index1/talk -d '{  
"\_boost":2,  
"speaker" : "Michaël Chaize",  
"title" : "Architecting user-experiences"  
}'

While querying:  
curl -XGET [http://localhost:9200/index1/\_search?pretty=true](http://localhost:9200/index1/_search?pretty=true) -d '{  
"custom\_filters\_score" : {  
"query" : {  
"match\_all" : {}  
},  
"filter" : { "term":{"speaker":"Chaize"} },  
"boost" : "3"  
}  
}'

then its giving error like this:  
{  
"error" : "SearchPhaseExecutionException[Failed to execute phase [query],  
total failure; shardFailures {[6-5lEX1OTViQqCiC7uHEQA][index1][1]:  
SearchParseException[[index1][1]: from[-1],size[-1]: Parse Failure [Failed  
to parse source [{\n "custom\_filters\_score" : {\n "query" :  
{\n "match\_all" : {}\n }, \n \n  
"boost" : "3" \n}\n}]]]; nested:  
SearchParseException[[index1][1]: from[-1],size[-1]: Parse Failure [No  
parser for element [custom\_filters\_score]]];  
}{[kzX9mMdKTmaATpUKj9-jGA][index1][0]: RemoteTransportException[[U-Go Girl][inet[/192.168.1.16:9301]][search/phase/query]]; nested:  
SearchParseException[[index1][0]: from[-1],size[-1]: Parse Failure [Failed  
to parse source [{\n "custom\_filters\_score" : {\n "query" :  
{\n "match\_all" : {}\n }, \n \n  
"boost" : "3" \n}\n}]]]; nested:  
SearchParseException[[index1][0]: from[-1],size[-1]: Parse Failure [No  
parser for element [custom\_filters\_score]]]; }]",  
"status" : 500  
}

Is it the correct way of doing?If not plz explain me clearly..

On Tue, Dec 13, 2011 at 2:10 AM, Karussell [tableyourtime@googlemail.com](mailto:tableyourtime@googlemail.com)wrote:

> On 12 Dez., 14:57, kalyan chowdary [kalyanc...@gmail.com](mailto:kalyanc...@gmail.com) wrote:
> 
> > Thanks !!  
> > Do u have any examples to write java code for this?
> 
> for which concrete example?
> 
> QueryBuilders.customScoreQuery(QueryBuilders.matchAllQuery()).script("mybooster").lang("native").param("friends",  
> friends)
> 
> QueryBuilders.boostingQuery().positive(QueryBuilders.fieldQuery("someField",  
> 12)).negative(QueryBuilders.termsQuery("names", "peter", "ron",  
> "don"));
> 
> while indexing you'll need to set the \_boost:  
> XContentBuilder b = JsonXContent.contentBuilder().startObject();  
> b.field("url", url);  
> b.field("\_boost", someCustomScore);  
> ...  
> b.endObject();  
> addToYourBulkIndexing(b);
> 
> Peter.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [December 13, 2011, 8:17am UTC](https://discuss.elastic.co/t/about-score-of-a-document/6125/6 "2011-12-13T08:17:22Z")

</div>

I didn't test it but if I read correctly this :

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

{

"custom\_filters\_score"

:

{

"query"

:

{

"match\_all"

:

{}

},

"filters"

:

[

{

"filter"

:

{

"range"

:

{

"age"

:

{  
"from"

:

0  
,

"to"

:

10  
}

}

},

"boost"

:

"3"

},

{

"filter"

:

{

"range"

:

{

"age"

:

{  
"from"

:

10  
,

"to"

:

20  
}

}

},

"boost"

:

"2"

}

]

}

}

You have to put filter in a filters array.

Not sure that's your concern here but hope this could help.

David.

Le 13 décembre 2011 à 08:12, kalyan chowdary [kalyanc007@gmail.com](mailto:kalyanc007@gmail.com) a écrit :

> Intially I want to start with curl commands like below:
> 
> While idexing I set the boost here:  
> curl -XPOST localhost:9200/index1/talk -d '{  
> "\_boost":2,  
> "speaker" : "Michaël Chaize",  
> "title" : "Architecting user-experiences"  
> }'
> 
> While querying:  
> curl -XGET [http://localhost:9200/index1/\_search?pretty=true](http://localhost:9200/index1/_search?pretty=true) -d '{  
> "custom\_filters\_score" : {  
> "query" : {  
> "match\_all" : {}  
> },  
> "filter" : { "term":{"speaker":"Chaize"} },  
> "boost" : "3"  
> }  
> }'
> 
> then its giving error like this:  
> {  
> "error" : "SearchPhaseExecutionException[Failed to execute phase [query],  
> total failure; shardFailures {[6-5lEX1OTViQqCiC7uHEQA][index1][1]:  
> SearchParseException[[index1][1]: from[-1],size[-1]: Parse Failure [Failed  
> to parse source [{\n "custom\_filters\_score" : {\n "query" :  
> {\n "match\_all" : {}\n }, \n \n  
> "boost" : "3" \n}\n}]]]; nested:  
> SearchParseException[[index1][1]: from[-1],size[-1]: Parse Failure [No  
> parser for element [custom\_filters\_score]]];  
> }{[kzX9mMdKTmaATpUKj9-jGA][index1][0]: RemoteTransportException[[U-Go Girl][inet[/192.168.1.16:9301]][search/phase/query]]; nested:  
> SearchParseException[[index1][0]: from[-1],size[-1]: Parse Failure [Failed  
> to parse source [{\n "custom\_filters\_score" : {\n "query" :  
> {\n "match\_all" : {}\n }, \n \n  
> "boost" : "3" \n}\n}]]]; nested:  
> SearchParseException[[index1][0]: from[-1],size[-1]: Parse Failure [No  
> parser for element [custom\_filters\_score]]]; }]",  
> "status" : 500  
> }
> 
> Is it the correct way of doing?If not plz explain me clearly..
> 
> On Tue, Dec 13, 2011 at 2:10 AM, Karussell  
> [tableyourtime@googlemail.com](mailto:tableyourtime@googlemail.com)wrote:
> 
> > On 12 Dez., 14:57, kalyan chowdary [kalyanc...@gmail.com](mailto:kalyanc...@gmail.com) wrote:
> > 
> > > Thanks !!  
> > > Do u have any examples to write java code for this?
> > 
> > for which concrete example?
> > 
> > QueryBuilders.customScoreQuery(QueryBuilders.matchAllQuery()).script("mybooster").lang("native").param("friends",  
> > friends)
> > 
> > QueryBuilders.boostingQuery().positive(QueryBuilders.fieldQuery("someField",  
> > 12)).negative(QueryBuilders.termsQuery("names", "peter", "ron",  
> > "don"));
> > 
> > while indexing you'll need to set the \_boost:  
> > XContentBuilder b = JsonXContent.contentBuilder().startObject();  
> > b.field("url", url);  
> > b.field("\_boost", someCustomScore);  
> > ...  
> > b.endObject();  
> > addToYourBulkIndexing(b);
> > 
> > Peter.

--  
David Pilato  
[http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
Twitter : @dadoonet

---

<div class="post-metadata">

### Author: ![BARNEY](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@BARNEY](https://discuss.elastic.co/u/BARNEY)
#### Post date: [December 13, 2011, 8:37am UTC](https://discuss.elastic.co/t/about-score-of-a-document/6125/7 "2011-12-13T08:37:50Z")

</div>

I think adding array filter doesnt matter.Its giving error even I query  
like this:

curl -XGET [http://localhost:9200/index1/\_search?pretty=true](http://localhost:9200/index1/_search?pretty=true) -d '{  
"custom\_filters\_score" : {  
"query" : {  
"match\_all" : {}  
},  
"filters" : [  
{  
"filter" : { "term" : {"speaker":"Chaize"} },  
"boost" : "3"  
},  
{  
"filter" : { "term" : {"title":"user"} },  
"boost" : "2"  
}  
]  
}  
}'

On Tue, Dec 13, 2011 at 1:47 PM, [david@pilato.fr](mailto:david@pilato.fr) [david@pilato.fr](mailto:david@pilato.fr) wrote:

> \*\*
> 
> I didn't test it but if I read correctly this :  
> [http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.html)
> 
> {
> 
> "custom\_filters\_score"
> 
> :
> 
> {
> 
> "query"
> 
> :
> 
> {
> 
> "match\_all"
> 
> :
> 
> {}
> 
> },
> 
> "filters"
> 
> :
> 
> [
> 
> {
> 
> "filter"
> 
> :
> 
> {
> 
> "range"
> 
> :
> 
> {
> 
> "age"
> 
> :
> 
> {  
> "from"
> 
> :
> 
> 0  
> ,
> 
> "to"
> 
> :
> 
> 10  
> }
> 
> }
> 
> },
> 
> "boost"
> 
> :
> 
> "3"
> 
> },
> 
> {
> 
> "filter"
> 
> :
> 
> {
> 
> "range"
> 
> :
> 
> {
> 
> "age"
> 
> :
> 
> {  
> "from"
> 
> :
> 
> 10  
> ,
> 
> "to"
> 
> :
> 
> 20  
> }
> 
> }
> 
> },
> 
> "boost"
> 
> :
> 
> "2"
> 
> }
> 
> ]
> 
> }
> 
> }
> 
> You have to put filter in a filters array.
> 
> Not sure that's your concern here but hope this could help.
> 
> David.
> 
> Le 13 décembre 2011 à 08:12, kalyan chowdary [kalyanc007@gmail.com](mailto:kalyanc007@gmail.com) a  
> écrit :
> 
> > Intially I want to start with curl commands like below:
> > 
> > While idexing I set the boost here:  
> > curl -XPOST localhost:9200/index1/talk -d '{  
> > "\_boost":2,  
> > "speaker" : "Michaël Chaize",  
> > "title" : "Architecting user-experiences"  
> > }'
> > 
> > While querying:  
> > curl -XGET [http://localhost:9200/index1/\_search?pretty=true](http://localhost:9200/index1/_search?pretty=true) -d '{  
> > "custom\_filters\_score" : {  
> > "query" : {  
> > "match\_all" : {}  
> > },  
> > "filter" : { "term":{"speaker":"Chaize"} },  
> > "boost" : "3"  
> > }  
> > }'
> > 
> > then its giving error like this:  
> > {  
> > "error" : "SearchPhaseExecutionException[Failed to execute phase  
> > [query],  
> > total failure; shardFailures {[6-5lEX1OTViQqCiC7uHEQA][index1][1]:  
> > SearchParseException[[index1][1]: from[-1],size[-1]: Parse Failure  
> > [Failed  
> > to parse source [{\n "custom\_filters\_score" : {\n "query"  
> > :  
> > {\n "match\_all" : {}\n }, \n \n  
> > "boost" : "3" \n}\n}]]]; nested:  
> > SearchParseException[[index1][1]: from[-1],size[-1]: Parse Failure [No  
> > parser for element [custom\_filters\_score]]];  
> > }{[kzX9mMdKTmaATpUKj9-jGA][index1][0]: RemoteTransportException[[U-Go Girl][inet[/192.168.1.16:9301]][search/phase/query]]; nested:  
> > SearchParseException[[index1][0]: from[-1],size[-1]: Parse Failure  
> > [Failed  
> > to parse source [{\n "custom\_filters\_score" : {\n "query"  
> > :  
> > {\n "match\_all" : {}\n }, \n \n  
> > "boost" : "3" \n}\n}]]]; nested:  
> > SearchParseException[[index1][0]: from[-1],size[-1]: Parse Failure [No  
> > parser for element [custom\_filters\_score]]]; }]",  
> > "status" : 500  
> > }
> > 
> > Is it the correct way of doing?If not plz explain me clearly..
> > 
> > On Tue, Dec 13, 2011 at 2:10 AM, Karussell [tableyourtime@googlemail.com](mailto:tableyourtime@googlemail.com)wrote:
> 
> > > On 12 Dez., 14:57, kalyan chowdary [kalyanc...@gmail.com](mailto:kalyanc...@gmail.com) wrote:
> > > 
> > > > Thanks !!  
> > > > Do u have any examples to write java code for this?
> > > 
> > > for which concrete example?
> 
> QueryBuilders.customScoreQuery(QueryBuilders.matchAllQuery()).script("mybooster").lang("native").param("friends",
> 
> > > friends)
> 
> QueryBuilders.boostingQuery().positive(QueryBuilders.fieldQuery("someField",
> 
> > > 12)).negative(QueryBuilders.termsQuery("names", "peter", "ron",  
> > > "don"));
> > > 
> > > while indexing you'll need to set the \_boost:  
> > > XContentBuilder b = JsonXContent.contentBuilder().startObject();  
> > > b.field("url", url);  
> > > b.field("\_boost", someCustomScore);  
> > > ...  
> > > b.endObject();  
> > > addToYourBulkIndexing(b);
> > > 
> > > Peter.
> 
> --  
> David Pilato  
> [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
> Twitter : @dadoonet

---

<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, 3:45am UTC](https://discuss.elastic.co/t/about-score-of-a-document/6125/8 "2017-07-06T03:45:36Z")

</div>


