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 [email protected].
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.

Reply via email to