About score of a document


(BARNEY) #1

How to increase the score for a particular record?


(Karussell) #2

boost it while indexing

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/boosting-query.html

etc

Peter.

On 12 Dez., 09:51, BARNEY kalyanc...@gmail.com wrote:

How to increase the score for a particular record?


(BARNEY) #3

Thanks !!
Do u have any examples to write java code for this?
On Mon, Dec 12, 2011 at 2:50 PM, Karussell tableyourtime@googlemail.comwrote:

boost it while indexing

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/boosting-query.html

etc

Peter.

On 12 Dez., 09:51, BARNEY kalyanc...@gmail.com wrote:

How to increase the score for a particular record?


(Karussell) #4

On 12 Dez., 14:57, kalyan chowdary 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.


(BARNEY) #5

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 -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.comwrote:

On 12 Dez., 14:57, kalyan chowdary 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) #6

I didn't test it but if I read correctly this :
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 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 -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.comwrote:

On 12 Dez., 14:57, kalyan chowdary 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/
Twitter : @dadoonet


(BARNEY) #7

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

curl -XGET 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 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

{

"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 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 -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.comwrote:

On 12 Dez., 14:57, kalyan chowdary 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/
Twitter : @dadoonet


(system) #8