Passing parameter to native script

Hello!

Is there way to pass parameter to native script? For example, if I
execute query

{
"query": {
"custom_score": {
"query": { ... },
"params" : { "x" : "value" },
"lang":"native",
"script":"CustomScript"
}
}
}

  • how do I access value of "x" parameter in the native script
    CustomScript?

Thanks!

via params:

public ExecutableScript newScript(final Map<String, Object> params) {
return new AbstractFloatSearchScript() {

        @Override
        public float runAsFloat() {
            params.get("xy");

....
}}}

On Jun 30, 3:00 pm, Eugen Zagorodniy e.zagorod...@gmail.com wrote:

Hello!

Is there way to pass parameter to native script? For example, if I
execute query

{
"query": {
"custom_score": {
"query": { ... },
"params" : { "x" : "value" },
"lang":"native",
"script":"CustomScript"
}
}

}

  • how do I access value of "x" parameter in the native script
    CustomScript?

Thanks!

Hi.
I have a doubt about this.
Exactly where are we suppose to write this function.
I mean as we are returning AbstractFloatSearchScript I wrote this
function as a part of factory class.
Does this means class returned by my factory is nested class?
I didn't write Script.class at all.
My factory class is at https://gist.github.com/1073346.
Is there any mistake, because I am getting this error continously
git://gist.github.com/1073348.git.
Can anybody help me to where to include this function?

On Jul 2, 1:31 am, Karussell tableyourt...@googlemail.com wrote:

via params:

public ExecutableScript newScript(final Map<String, Object> params) {
return new AbstractFloatSearchScript() {

        @Override
        public float runAsFloat() {
            params.get("xy");

....

}}}

On Jun 30, 3:00 pm, Eugen Zagorodniy e.zagorod...@gmail.com wrote:

Hello!

Is there way to pass parameter tonativescript? For example, if I
execute query

{
"query": {
"custom_score": {
"query": { ... },
"params" : { "x" : "value" },
"lang":"native",
"script":"CustomScript"
}
}

}

  • how do I access value of "x" parameter in thenativescript
    CustomScript?

Thanks!

It can be an inner class, or another class defined, it does not matter. Can you post your config based on the same code you provided?

On Monday, July 11, 2011 at 6:53 AM, nachiket bhagwat wrote:

Hi.
I have a doubt about this.
Exactly where are we suppose to write this function.
I mean as we are returning AbstractFloatSearchScript I wrote this
function as a part of factory class.
Does this means class returned by my factory is nested class?
I didn't write Script.class at all.
My factory class is at https://gist.github.com/1073346.
Is there any mistake, because I am getting this error continously
git://gist.github.com/1073348.git (http://gist.github.com/1073348.git).
Can anybody help me to where to include this function?

On Jul 2, 1:31 am, Karussell <tableyourt...@googlemail.com (http://googlemail.com)> wrote:

via params:

public ExecutableScript newScript(final Map<String, Object> params) {
return new AbstractFloatSearchScript() {

@Override
public float runAsFloat() {
params.get("xy");
....

}}}

On Jun 30, 3:00 pm, Eugen Zagorodniy <e.zagorod...@gmail.com (http://gmail.com)> wrote:

Hello!

Is there way to pass parameter tonativescript? For example, if I
execute query

{
"query": {
"custom_score": {
"query": { ... },
"params" : { "x" : "value" },
"lang":"native",
"script":"CustomScript"
}
}

}

  • how do I access value of "x" parameter in thenativescript
    CustomScript?

Thanks!

My Config file.
script.native.foo.type:
in.vedantu.search.scripts.SampleScriptFactory.

Actually I am able to access params in newScript function of
SampleScriptFactory.
But if I don't create SampleScript.java, then I get error I mentioned
earlier.
If I create SampleSctipt.java then I can't access params.

On Jul 11, 10:06 pm, Shay Banon shay.ba...@elasticsearch.com wrote:

It can be an inner class, or another class defined, it does not matter. Can you post your config based on the same code you provided?

On Monday, July 11, 2011 at 6:53 AM, nachiket bhagwat wrote:

Hi.
I have a doubt about this.
Exactly where are we suppose to write this function.
I mean as we are returning AbstractFloatSearchScript I wrote this
function as a part of factory class.
Does this means class returned by my factory is nested class?
I didn't write Script.class at all.
My factory class is athttps://gist.github.com/1073346.
Is there any mistake, because I am getting this error continously
git://gist.github.com/1073348.git (http://gist.github.com/1073348.git).
Can anybody help me to where to include this function?

On Jul 2, 1:31 am, Karussell <tableyourt...@googlemail.com (http://googlemail.com)> wrote:

via params:

public ExecutableScript newScript(final Map<String, Object> params) {
return new AbstractFloatSearchScript() {

@Override
public float runAsFloat() {
params.get("xy");
....

}}}

On Jun 30, 3:00 pm, Eugen Zagorodniy <e.zagorod...@gmail.com (http://gmail.com)> wrote:

Hello!

Is there way to pass parameter tonativescript? For example, if I
execute query

{
"query": {
"custom_score": {
"query": { ... },
"params" : { "x" : "value" },
"lang":"native",
"script":"CustomScript"
}
}

}

  • how do I access value of "x" parameter in thenativescript
    CustomScript?

Thanks!

Hi. Can anybody help on above issue ?

On Jul 13, 12:58 pm, nachiket bhagwat nachiketbhag...@gmail.com
wrote:

My Config file.script.native.foo.type:
in.vedantu.search.scripts.SampleScriptFactory.

Actually I am able to access params in newScript function of
SampleScriptFactory.
But if I don't create SampleScript.java, then I get error I mentioned
earlier.
If I create SampleSctipt.java then I can't access params.

On Jul 11, 10:06 pm, Shay Banon shay.ba...@elasticsearch.com wrote:

It can be an inner class, or another class defined, it does not matter. Can you post your config based on the same code you provided?

On Monday, July 11, 2011 at 6:53 AM, nachiket bhagwat wrote:

Hi.
I have a doubt about this.
Exactly where are we suppose to write this function.
I mean as we are returning AbstractFloatSearchScript I wrote this
function as a part of factory class.
Does this means class returned by my factory is nested class?
I didn't writeScript.class at all.
My factory class is athttps://gist.github.com/1073346.
Is there any mistake, because I am getting this error continously
git://gist.github.com/1073348.git (http://gist.github.com/1073348.git).
Can anybody help me to where to include this function?

On Jul 2, 1:31 am, Karussell <tableyourt...@googlemail.com (http://googlemail.com)> wrote:

via params:

public ExecutableScript newScript(final Map<String, Object> params) {
return new AbstractFloatSearchScript() {

@Override
public float runAsFloat() {
params.get("xy");
....

}}}

On Jun 30, 3:00 pm, Eugen Zagorodniy <e.zagorod...@gmail.com (http://gmail.com)> wrote:

Hello!

Is there way to passparametertonativescript? For example, if I
execute query

{
"query": {
"custom_score": {
"query": { ... },
"params" : { "x" : "value" },
"lang":"native",
"script":"CustomScript"
}
}

}

  • how do I access value of "x"parameterin thenativescript
    CustomScript?

Thanks!