doc['timesGoogleplus'].value + doc['timesReddit'].value) * param5;
if (time > 365){
score * param13 * _score;
}
else if (time > 279){
score * param12 * _score;
}
else if (time > 186){
score * param11 * _score;
}
else if (time > 93){
score * param10 * _score;
}
else if (time > 31){
score * param9 * _score;
}
else if (time > 7){
score * param8 * _score;
}
else if (time > 1){
score * param7 * _score;
}
else {
score * param6 * _score;
}
With the following parameters:
array(
'param1' => self::SCORE_NB_POST_VIEWS,
'param2' => self::SCORE_NB_POST_COMMENTED,
'param3' => self::SCORE_NB_POST_OLOGIZED,
'param4' => self::SCORE_NB_POST_LIKE,
'param5' => self::SCORE_NB_EXTERNAL_SHARES,
'param6' => self::TM_POST_TODAY,
'param7' => self::TM_POST_THIS_WEEK,
'param8' => self::TM_POST_THIS_MONTH,
'param9' => self::TM_POST_THREE_MONTH,
'param10' => self::TM_POST_SIX_MONTH,
'param11' => self::TM_POST_NINE_MONTH,
'param12' => self::TM_POST_THIS_YEAR,
'param13' => self::TM_POST_OLDER_YEAR,
'param14' => $this->today
)
Apparently $time is not set as it should be because it seems to go in the
last else each time!
$time should be the number of days since the document has been created with
creationDate the creation timestamp and param14 is the actual timestamp
calculate with time() (PHP). I also tried to return score at the end but
it did not change anything...
Is there something wrong in my script? How can I test it? Is there a way to
print variable?
Thank you for your help!
I typically test such scripts one step at a time using script_field.
script_field makes it much easier to see what's getting returned for each
record. You can print from the screen to stdout using
System.out.println(....) but this is only useful if you run elasticsearch
locally in foreground mode. Alternatively, you can write messages into the
log file using this somewhat convoluted
call: org.elasticsearch.common.logging.Loggers.getLogger("my_logger").info("message
from the script");
On Thursday, April 18, 2013 4:16:47 PM UTC-4, Damien wrote:
Hello everyone,
I tried to make a script and use it to calculate my own score but it does
not act like it should be.
Here is my script:
time = (param14 - doc['creationDate'].value) / 86400; // 1 day = 86400sec
score = doc['timesViewed'].value *
param1 +
doc['timesOlogized'].value
doc['timesGoogleplus'].value + doc['timesReddit'].value) * param5;
if (time > 365){
score * param13 * _score;
}
else if (time > 279){
score * param12 * _score;
}
else if (time > 186){
score * param11 * _score;
}
else if (time > 93){
score * param10 * _score;
}
else if (time > 31){
score * param9 * _score;
}
else if (time > 7){
score * param8 * _score;
}
else if (time > 1){
score * param7 * _score;
}
else {
score * param6 * _score;
}
With the following parameters:
array(
'param1' => self::SCORE_NB_POST_VIEWS,
'param2' => self::SCORE_NB_POST_COMMENTED,
'param3' => self::SCORE_NB_POST_OLOGIZED,
'param4' => self::SCORE_NB_POST_LIKE,
'param5' => self::SCORE_NB_EXTERNAL_SHARES,
'param6' => self::TM_POST_TODAY,
'param7' => self::TM_POST_THIS_WEEK,
'param8' => self::TM_POST_THIS_MONTH,
'param9' => self::TM_POST_THREE_MONTH,
'param10' => self::TM_POST_SIX_MONTH,
'param11' => self::TM_POST_NINE_MONTH,
'param12' => self::TM_POST_THIS_YEAR,
'param13' => self::TM_POST_OLDER_YEAR,
'param14' => $this->today
)
Apparently $time is not set as it should be because it seems to go in the
last else each time!
$time should be the number of days since the document has been created
with creationDate the creation timestamp and param14 is the actual
timestamp calculate with time() (PHP). I also tried to return score at the
end but it did not change anything...
Is there something wrong in my script? How can I test it? Is there a way
to print variable?
Thank you for your help!
Yeah log file is better than nothing. Thanks for the line but I'm using
elasticsearch in PHP environment and I'm not sure there is log system like
in Java.
So I don't know how to call getLogger()... I'm going to search how to call
it now.
On Thursday, April 18, 2013 5:14:16 PM UTC-4, Damien wrote:
Yeah log file is better than nothing. Thanks for the line but I'm using
elasticsearch in PHP environment and I'm not sure there is log system like
in Java.
So I don't know how to call getLogger()... I'm going to search how to call
it now.
It seems to work, I mean there is no error when executing the script.
Now I just have to find where is this log file if it actually worked.
Thanks again.
On Thursday, April 18, 2013 5:48:28 PM UTC-4, Damien wrote:
It seems to work, I mean there is no error when executing the script.
Now I just have to find where is this log file if it actually worked.
Thanks again.
Yes! It works thank you. I can see now that my time variable is null each
time. Apparently you cannot use the word 'time' as a variable, it might be
a key word for MVEL. I just changed the name time in timeModifier and it
works. This would have been impossible to figure it out without log. Thanks!
Le jeudi 18 avril 2013 18:24:37 UTC-4, Igor Motov a écrit :
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.