Loading and Registering Native Scripts

I've created a class com.thomas.ObjectSearchScript that extends
AbstractFloatSearchScript. The documentation on native scripting
isn't too clear to me. I assume creating a jar containing just my
class and placing it into the lib directory will load the class. How
do I actually register it through settings or in a plugin using
ScriptModule?

I'd like to eventually be able to use my class by issuing the
following query:

{
"query":{
"custom_score":{
"query":{
"query_string":{
"default_field":"title",
"query":"grand theft auto"
}
},
"lang":"native",
"script":"ObjectSearchScript "
}
}
}

Did you try to give in the query the full classname ? With the package ?

"script":"com.thomas.ObjectSearchScript "

Hope this helps

David :wink:

Le 21 juin 2011 à 03:04, thnguyen tsxn26@gmail.com a écrit :

I've created a class com.thomas.ObjectSearchScript that extends
AbstractFloatSearchScript. The documentation on native scripting
isn't too clear to me. I assume creating a jar containing just my
class and placing it into the lib directory will load the class. How
do I actually register it through settings or in a plugin using
ScriptModule?

I'd like to eventually be able to use my class by issuing the
following query:

{
"query":{
"custom_score":{
"query":{
"query_string":{
"default_field":"title",
"query":"grand theft auto"
}
},
"lang":"native",
"script":"ObjectSearchScript "
}
}
}

Sorry wrong answer :
Did you put your script in settings ?

Registering them can either be done by settings, for example: script.native.my.type set tosample.MyNativeScriptFactory will register a script named my.

Did you try to give in the query the full classname ? With the package ?

"script":"com.thomas.ObjectSearchScript "

Hope this helps

David :wink:

Le 21 juin 2011 à 03:04, thnguyen tsxn26@gmail.com a écrit :

I've created a class com.thomas.ObjectSearchScript that extends
AbstractFloatSearchScript. The documentation on native scripting
isn't too clear to me. I assume creating a jar containing just my
class and placing it into the lib directory will load the class. How
do I actually register it through settings or in a plugin using
ScriptModule?

I'd like to eventually be able to use my class by issuing the
following query:

{
"query":{
"custom_score":{
"query":{
"query_string":{
"default_field":"title",
"query":"grand theft auto"
}
},
"lang":"native",
"script":"ObjectSearchScript "
}
}
}

I tried that out but the native script cannot be found when issuing
the query. Here's how I modified my settings:

curl -XPUT 'http://localhost/media/_settings' -d '{ "index" :
{ "script.native.my.type" : "com.thomas.ObjectSearchScript" } }'

Here are what my settings look like after modifying them:

{"media":{"settings":
{"index.number_of_replicas":"1","index.number_of_shards":"1","index.index":"media","index.script.native.my.type":"com.thomas.ObjectSearchScript"}}}

Here is my query:

{
"query":{
"custom_score":{
"query":{
"query_string":{
"default_field":"title",
"query":"grand theft auto"
}
},
"lang":"native",
"script":"my "
}
}

BTW, I also created a plugins directory under $ES_HOME and copied my
jar to the directory in addition to $ES_HOME/lib.

On Jun 20, 9:46 pm, David Pilato da...@pilato.fr wrote:

Sorry wrong answer :
Did you put your script in settings ?

Registering them can either be done by settings, for example: script.native.my.type set tosample.MyNativeScriptFactory will register a script named my.Elasticsearch Platform — Find real-time answers at scale | Elastic

Did you try to give in the query the full classname ? With the package ?

"script":"com.thomas.ObjectSearchScript "

Hope this helps

David :wink:

Le 21 juin 2011 à 03:04, thnguyen tsx...@gmail.com a écrit :

I've created a class com.thomas.ObjectSearchScript that extends
AbstractFloatSearchScript. The documentation on native scripting
isn't too clear to me. I assume creating a jar containing just my
class and placing it into the lib directory will load the class. How
do I actually register it through settings or in a plugin using
ScriptModule?

I'd like to eventually be able to use my class by issuing the
following query:

{
"query":{
"custom_score":{
"query":{
"query_string":{
"default_field":"title",
"query":"grand theft auto"
}
},
"lang":"native",
"script":"ObjectSearchScript "
}
}
}

It seems that you have a blank after "my" here :
"lang":"native",
"script":"my "

Try to remove the blank.

Hope this helps

-----Message d'origine-----
De : thnguyen [mailto:tsxn26@gmail.com]
Envoyé : mardi 21 juin 2011 20:10
À : users
Objet : Re: Loading and Registering Native Scripts

I tried that out but the native script cannot be found when issuing
the query. Here's how I modified my settings:

curl -XPUT 'http://localhost/media/_settings' -d '{ "index" :
{ "script.native.my.type" : "com.thomas.ObjectSearchScript" } }'

Here are what my settings look like after modifying them:

{"media":{"settings":
{"index.number_of_replicas":"1","index.number_of_shards":"1","index.index":"
media","index.script.native.my.type":"com.thomas.ObjectSearchScript"}}}

Here is my query:

{
"query":{
"custom_score":{
"query":{
"query_string":{
"default_field":"title",
"query":"grand theft auto"
}
},
"lang":"native",
"script":"my "
}
}

BTW, I also created a plugins directory under $ES_HOME and copied my
jar to the directory in addition to $ES_HOME/lib.