Document boosting vs function score boosting

Hello all!

I am new to ElasticSearch and I am trying to move some of my documents to
the top of the search results. (I have a "is_premium" field in my documents
and also a "popularity" value that is calculated by our system) The premium
documents should always be on the top of the search results (huge boost
factor) and popularity value should change the ordering of the rest of the
search results (small boost factor)

So I think I need some document boosting. I already have added a "boost"
value when adding documents to the index. This works as expected for
putting all "is_premium" documents to the top.
But now I have read in a blog post [1] that this way of doing things is
deprecated. A better way of boosting this is doing a function score query
where you calculate the boost value on query time, not on index time like
with document boosting.

So my question are:

a) Is document boosting on index time really deprecated and if yes, why?

b) I need some in wrapping my head around creating a custom query with
function score boosting (I use Django Haystack with Elastic-Search so no
manual query creation was necessary up until now.)
This is the test query I put together:

{
"query": {
"function_score": {
"query": {
"bool": {
"must": [
{
"query_string": {
"default_field": "_all",
"query": "tour de france"
}
}
]
}
},
"script_score": {
"script": "_score * 1000 * doc['popularity'].value"
}
}
}
}

But I get an error which I do not understand:
QueryParsingException[[haystack] script_score the script could not be
loaded]; nested: ScriptException[dynamic scripting for [mvel] disabled]

Has anyone some tips for me on how to get this query working?

Thanks in advance!
Anton

1: http://blog.brusic.com/2014/02/document-boosting-in-elasticsearch.html

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/ffc701fd-c859-4506-a0df-7e8f31a8b6bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Look into field value factor, which was added in 1.2

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#_field_value_factor

--
Ivan
On Oct 7, 2014 9:01 AM, "Anton Pirker" anton@ignaz.at wrote:

Hello all!

I am new to ElasticSearch and I am trying to move some of my documents to
the top of the search results. (I have a "is_premium" field in my documents
and also a "popularity" value that is calculated by our system) The premium
documents should always be on the top of the search results (huge boost
factor) and popularity value should change the ordering of the rest of the
search results (small boost factor)

So I think I need some document boosting. I already have added a "boost"
value when adding documents to the index. This works as expected for
putting all "is_premium" documents to the top.
But now I have read in a blog post [1] that this way of doing things is
deprecated. A better way of boosting this is doing a function score query
where you calculate the boost value on query time, not on index time like
with document boosting.

So my question are:

a) Is document boosting on index time really deprecated and if yes, why?

b) I need some in wrapping my head around creating a custom query with
function score boosting (I use Django Haystack with Elastic-Search so no
manual query creation was necessary up until now.)
This is the test query I put together:

{
"query": {
"function_score": {
"query": {
"bool": {
"must": [
{
"query_string": {
"default_field": "_all",
"query": "tour de france"
}
}
]
}
},
"script_score": {
"script": "_score * 1000 * doc['popularity'].value"
}
}
}
}

But I get an error which I do not understand:
QueryParsingException[[haystack] script_score the script could not be
loaded]; nested: ScriptException[dynamic scripting for [mvel] disabled]

Has anyone some tips for me on how to get this query working?

Thanks in advance!
Anton

1: http://blog.brusic.com/2014/02/document-boosting-in-elasticsearch.html

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/ffc701fd-c859-4506-a0df-7e8f31a8b6bf%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/ffc701fd-c859-4506-a0df-7e8f31a8b6bf%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCGv1YH82VxcxArfRet4uH2qZtHrHOaRv0xSzJAX9Woxg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.