can anyone help me over the scripting field. I am getting an error on running this
def x = doc['index_total'].value;
def y = doc['index_time_in_millis'].value;
{
if ( x > 0) {
def z = y / x;
return z
}
else {
def z = 5 * 0;
return z
}
}
if ( z > 0) {
def l = 0;
return l
}
else {
def f = 1;
return f
}
by creating the "indexing_latency" field and using it in the in loop but this is also throwing an error.
Please do not ping people not already active in the thread and also be patient. This forum is manned by volunteers, so there is no SLA. If you have not received any response within a few days it is generally fine to bump the issue.
When I read your issue, it is not clear exactly what you are trying to do. Can you please describe further? What is the loop you want too use it in? What does the error look like?
i am sorry @Christian_Dahlqvist
I am facing a issue
i want to create a script and the script is
def x = doc['index_total'].value;
def y = doc['index_time_in_millis'].value;
{
if ( x >; 0) {
def z = y / x;
return z
}
else {
def z = 5 * 0;
return z
}
}
if ( z > 0) {
def l = 0;
return l
}
else {
def f = 1;
return f
}
first i want to extract the value of Z after that i want to apply condition on that value i.e (z)
like if (z>0.3 && z<0.7) {
def l = 3;
retunr l
}
else {
def m = 0;
return m
}
Please format your code sample properly as it is hard to read. It looks like you are trying to do something like this:
def x = doc['index_total'].value;
def y = doc['index_time_in_millis'].value;
if ( x >; 0) {
def z = y / x;
return z
} else {
def z = 5 * 0;
return z
}
if ( z > 0) {
def l = 0;
return l
} else {
def f = 1;
return f
}
As you are calling return z the following if-else block will never be reached. If you describe what you expect your script to do it may be easier to help.
I want to first find the indexing latency which is (index_total / index_time_in_millis) and define it as Z.
Now I want that if Z is between (0.3 && 0.7) I want the final output (L) to be 1. and if Z is greater than (0.7 && less than 0.3) I want L to be 0.
def x = doc['index_total'].value;
def y = doc['index_time_in_millis'].value;
for ( x > 0) {
def z = y / x;
}
if (z > 0.3);
def t =1;
return t
}
else {
def m = 0;
return m
}
and i also tried this
def x = doc['index_total'].value;
def y = doc['index_time_in_millis'].value;
if ( x > 0) {
def z = y / x
}
else {
def z = 5*0
}
if (z > 0.3) {
def m = 1;
return m
}
else {
def m = 0;
return m
}
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.