Hi,
I understand I can use a custom_scorehttp://www.elasticsearch.org/guide/reference/query-dsl/custom-score-query.html  with 
script and that I can use script_fieldshttp://www.elasticsearch.org/guide/reference/api/search/script-fields.html  to 
calculate fields.
Now, what I want to do is to reuse the value generated with the 
script_field to use in score calculation. The script I use is quite heavy 
so I don’t really want to duplicate it.
Basically, I want something like this:
{ 
"query": { 
"custom_score" : { 
"query" : { 
"match_all" : {} 
}, 
"script" : "_score * (1 + my_complex_field * 0.2)" 
} 
}, 
"script_fields" : { 
"my_complex_field" : { 
"script" : "my_complex_script", 
"params": { 
"max_date": 1342017125, 
"min_date": 1340289125 
} 
} 
} 
}
Any ideas ?
Thanks
             
            
               
               
               
            
            
           
          
            
            
              Otherwise, is it possible to define a MVEL function on a global level (or 
in the index) and simply call this function everywhere ?
On Wednesday, July 11, 2012 2:01:33 PM UTC-4, Sebastien Lavoie wrote:
Hi,
I understand I can use a custom_scorehttp://www.elasticsearch.org/guide/reference/query-dsl/custom-score-query.html  with 
script and that I can use script_fieldshttp://www.elasticsearch.org/guide/reference/api/search/script-fields.html  to 
calculate fields.
Now, what I want to do is to reuse the value generated with the 
script_field to use in score calculation. The script I use is quite heavy 
so I don’t really want to duplicate it.
Basically, I want something like this:
{ 
"query": { 
"custom_score" : { 
"query" : { 
"match_all" : {} 
}, 
"script" : "_score * (1 + my_complex_field * 0.2)" 
} 
}, 
"script_fields" : { 
"my_complex_field" : { 
"script" : "my_complex_script", 
"params": { 
"max_date": 1342017125, 
"min_date": 1340289125 
} 
} 
} 
}
Any ideas ?
Thanks
 
             
            
               
               
               
            
            
           
          
            
              
                micherr  
                (micherr)
               
              
                  
                    November 18, 2013, 10:54am
                   
                   
              3 
               
             
            
              Hi!
If there any updates on the subject? I`m facing the same issue.
             
            
               
               
               
            
            
           
          
            
            
              I am sorry, I was never able to make it work, I had to use it twice.
-- 
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 . 
For more options, visit https://groups.google.com/groups/opt_out .
             
            
               
               
               
            
            
           
          
            
              
                spinscale  
                (Alexander Reelsen)
               
                 
              
                  
                    November 21, 2013,  9:03am
                   
                   
              5 
               
             
            
              Hey,
defining global scripts will not help your problem, but at least make it 
easier to execute/maintain, more about that
  
  
    
  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.
   
  
    
    
  
  
 
iirc it is not possible to access the script fields in your score. I am 
wondering, if you cant just use the score to go on? 
Also you might want to use the function_score query,
  
  
    
  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.
   
  
    
    
  
  
 
--Alex
On Tue, Nov 19, 2013 at 2:13 AM, Sébastien Lavoie sebastien@lavoie.sl wrote:
I am sorry, I was never able to make it work, I had to use it twice.
-- 
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 . 
For more options, visit https://groups.google.com/groups/opt_out .
 
-- 
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 . 
For more options, visit https://groups.google.com/groups/opt_out .