Custom functions for query

Hi All,

I want to use some custom functions in elastic-search query.

I want to write my own function and use that while searching the records in
elastic-search.

for example:
i have a field "field1" having double value. Now i want to get all records
matching some conditions and also get cuberoot of field1 in each record.

Logical query for same will look like:
select *, cuberoot("field1") from index where condition1 and condition2;

Other example:

i have a field "field2" having string value. Now i want to get all records
matching some conditions and also get reverse of field2 in each record.

Logical query for same will look like:
select *, reverse("field2") from index where condition1 and condition2;

There are some inbuilt mvel functions as mention
herehttp://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html#_mvel_built_in_functionsthat
can be used within scripts. I want to use some custom function in
similar way of mvel inbuilt functions.

Is it possible to register some custom functions for query ?

Any suggestions would me really helpful.

--
Thanks & Regards
Hanish Bansal

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAB0WE8a3ALbcWgjMXjW9ffQNvggzjBs7nHJLRdvLSd6Btnr%3D5g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Hanish,

Have you read on

?

It should be possible to change to other language other than mvel

These are some supported scripts

HTH

/Jason

On Thu, Dec 5, 2013 at 9:14 PM, Hanish Bansal <
hanish.bansal.agarwal@gmail.com> wrote:

Hi All,

I want to use some custom functions in elastic-search query.

I want to write my own function and use that while searching the records
in elastic-search.

for example:
i have a field "field1" having double value. Now i want to get all records
matching some conditions and also get cuberoot of field1 in each record.

Logical query for same will look like:
select *, cuberoot("field1") from index where condition1 and condition2;

Other example:

i have a field "field2" having string value. Now i want to get all records
matching some conditions and also get reverse of field2 in each record.

Logical query for same will look like:
select *, reverse("field2") from index where condition1 and condition2;

There are some inbuilt mvel functions as mention herehttp://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html#_mvel_built_in_functionsthat can be used within scripts. I want to use some custom function in
similar way of mvel inbuilt functions.

Is it possible to register some custom functions for query ?

Any suggestions would me really helpful.

--
Thanks & Regards
Hanish Bansal

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAB0WE8a3ALbcWgjMXjW9ffQNvggzjBs7nHJLRdvLSd6Btnr%3D5g%40mail.gmail.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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAHO4itznCurPqz9Yv9%3Dtkqt0dKOCGELnZPV1g8fGEsPcAEt2jg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks for response Jason !!

I gone through above links. My understanding is that we will have to do
below thing for this use case:

  1. Create a script in any supported lang. Write a custom function(lets say
    in javascript lang) for reverse a string:

function reverse(s) {
return s.split('').reverse().join('');
}

create a script file for this "reverse.js"

  1. Put this script file into config/scripts

  2. I''ll also need to install javascript lang plugin to support scripts
    written in javascript function.

  3. restart ES if i am using lower version than 0.90.6.

Using this i should be able to use custom function in my query.

Correct me i am missing anything.

Also i am not clear that how to use those functions in query. It would be
really helpful if you could put some examples for same.

On Thu, Dec 5, 2013 at 8:42 PM, Jason Wee peichieh@gmail.com wrote:

Hi Hanish,

Have you read on
Elasticsearch Platform — Find real-time answers at scale | Elastic
?

It should be possible to change to other language other than mvel
Elasticsearch Platform — Find real-time answers at scale | Elastic

These are some supported scripts
Elasticsearch Platform — Find real-time answers at scale | Elastic

HTH

/Jason

On Thu, Dec 5, 2013 at 9:14 PM, Hanish Bansal <
hanish.bansal.agarwal@gmail.com> wrote:

Hi All,

I want to use some custom functions in elastic-search query.

I want to write my own function and use that while searching the records
in elastic-search.

for example:
i have a field "field1" having double value. Now i want to get all
records matching some conditions and also get cuberoot of field1 in each
record.

Logical query for same will look like:
select *, cuberoot("field1") from index where condition1 and condition2;

Other example:

i have a field "field2" having string value. Now i want to get all
records matching some conditions and also get reverse of field2 in each
record.

Logical query for same will look like:
select *, reverse("field2") from index where condition1 and condition2;

There are some inbuilt mvel functions as mention herehttp://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html#_mvel_built_in_functionsthat can be used within scripts. I want to use some custom function in
similar way of mvel inbuilt functions.

Is it possible to register some custom functions for query ?

Any suggestions would me really helpful.

--
Thanks & Regards
Hanish Bansal

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAB0WE8a3ALbcWgjMXjW9ffQNvggzjBs7nHJLRdvLSd6Btnr%3D5g%40mail.gmail.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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAHO4itznCurPqz9Yv9%3Dtkqt0dKOCGELnZPV1g8fGEsPcAEt2jg%40mail.gmail.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
Thanks & Regards
Hanish Bansal

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAB0WE8YphAFh4_kYBZVyCyeGy1kt0gcjr2Y_%2Bh0vqQsiAvFPGQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Hanish,

You have collectively listed steps to perform, why don't try it and see? if
you stumble upon problems, that's when you get to learn really.

To help in your journey, please read the link below, there are a few
example,

http://mgranstrom.com/elasticsearch/2012/10/08/creating-a-native-script-for-elasticsearch.html

That should help in your journey and good luck!

/Jason

On Fri, Dec 6, 2013 at 2:44 PM, Hanish Bansal <
hanish.bansal.agarwal@gmail.com> wrote:

Thanks for response Jason !!

I gone through above links. My understanding is that we will have to do
below thing for this use case:

  1. Create a script in any supported lang. Write a custom function(lets
    say in javascript lang) for reverse a string:

function reverse(s) {
return s.split('').reverse().join('');
}

create a script file for this "reverse.js"

  1. Put this script file into config/scripts

  2. I''ll also need to install javascript lang plugin to support scripts
    written in javascript function.

  3. restart ES if i am using lower version than 0.90.6.

Using this i should be able to use custom function in my query.

Correct me i am missing anything.

Also i am not clear that how to use those functions in query. It would be
really helpful if you could put some examples for same.

On Thu, Dec 5, 2013 at 8:42 PM, Jason Wee peichieh@gmail.com wrote:

Hi Hanish,

Have you read on
Elasticsearch Platform — Find real-time answers at scale | Elastic
?

It should be possible to change to other language other than mvel
Elasticsearch Platform — Find real-time answers at scale | Elastic

These are some supported scripts
Elasticsearch Platform — Find real-time answers at scale | Elastic

HTH

/Jason

On Thu, Dec 5, 2013 at 9:14 PM, Hanish Bansal <
hanish.bansal.agarwal@gmail.com> wrote:

Hi All,

I want to use some custom functions in elastic-search query.

I want to write my own function and use that while searching the records
in elastic-search.

for example:
i have a field "field1" having double value. Now i want to get all
records matching some conditions and also get cuberoot of field1 in each
record.

Logical query for same will look like:
select *, cuberoot("field1") from index where condition1 and condition2;

Other example:

i have a field "field2" having string value. Now i want to get all
records matching some conditions and also get reverse of field2 in each
record.

Logical query for same will look like:
select *, reverse("field2") from index where condition1 and condition2;

There are some inbuilt mvel functions as mention herehttp://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html#_mvel_built_in_functionsthat can be used within scripts. I want to use some custom function in
similar way of mvel inbuilt functions.

Is it possible to register some custom functions for query ?

Any suggestions would me really helpful.

--
Thanks & Regards
Hanish Bansal

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAB0WE8a3ALbcWgjMXjW9ffQNvggzjBs7nHJLRdvLSd6Btnr%3D5g%40mail.gmail.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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAHO4itznCurPqz9Yv9%3Dtkqt0dKOCGELnZPV1g8fGEsPcAEt2jg%40mail.gmail.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
Thanks & Regards
Hanish Bansal

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAB0WE8YphAFh4_kYBZVyCyeGy1kt0gcjr2Y_%2Bh0vqQsiAvFPGQ%40mail.gmail.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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAHO4ity%3Ds5AGpkA1TfiP9P45ssgRD4Dm9CujnWX_gbo4EPm_hw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Jason,

Thanks for sharing the useful links.

I am trying to install sample plugin of native scripts given here
GitHub - imotov/elasticsearch-native-script-example: Example of Now Deprecated Native Script Plugin for Elasticsearch but i am
getting below exception:

    • Installing native-script-example...Failed to install
      native-script-example, reason: no protocol: ../elasticsearch-native-*
      *script-example-master/target/*releases/elasticsearch-native-
      *script-example-1.1.1-SNAPSHOT.*zip

Command used to install plugin is:

bin/plugin -i native-script-example -u
../elasticsearch-native-script-example-master/target/releases/elasticsearch-native-script-example-1.1.1-SNAPSHOT.zip

Name of plugin is "native-script-example" as mentioned in plugin class "
NativeScriptExamplesPlugin".

Please help!!

On Fri, Dec 6, 2013 at 2:44 PM, Jason Wee peichieh@gmail.com wrote:

Hi Hanish,

You have collectively listed steps to perform, why don't try it and see?
if you stumble upon problems, that's when you get to learn really.

To help in your journey, please read the link below, there are a few
example,
GitHub - imotov/elasticsearch-native-script-example: Example of Now Deprecated Native Script Plugin for Elasticsearch
GitHub - imotov/elasticsearch-facet-script: Fully Scriptable Facets for ElasticSearch

Service End for Bintray, JCenter, GoCenter, and ChartCenter | JFrog

http://mgranstrom.com/elasticsearch/2012/10/08/creating-a-native-script-for-elasticsearch.html

That should help in your journey and good luck!

/Jason

On Fri, Dec 6, 2013 at 2:44 PM, Hanish Bansal <
hanish.bansal.agarwal@gmail.com> wrote:

Thanks for response Jason !!

I gone through above links. My understanding is that we will have to do
below thing for this use case:

  1. Create a script in any supported lang. Write a custom function(lets
    say in javascript lang) for reverse a string:

function reverse(s) {
return s.split('').reverse().join('');
}

create a script file for this "reverse.js"

  1. Put this script file into config/scripts

  2. I''ll also need to install javascript lang plugin to support scripts
    written in javascript function.

  3. restart ES if i am using lower version than 0.90.6.

Using this i should be able to use custom function in my query.

Correct me i am missing anything.

Also i am not clear that how to use those functions in query. It would be
really helpful if you could put some examples for same.

On Thu, Dec 5, 2013 at 8:42 PM, Jason Wee peichieh@gmail.com wrote:

Hi Hanish,

Have you read on
Elasticsearch Platform — Find real-time answers at scale | Elastic
?

It should be possible to change to other language other than mvel
Elasticsearch Platform — Find real-time answers at scale | Elastic

These are some supported scripts
Elasticsearch Platform — Find real-time answers at scale | Elastic

HTH

/Jason

On Thu, Dec 5, 2013 at 9:14 PM, Hanish Bansal <
hanish.bansal.agarwal@gmail.com> wrote:

Hi All,

I want to use some custom functions in elastic-search query.

I want to write my own function and use that while searching the
records in elastic-search.

for example:
i have a field "field1" having double value. Now i want to get all
records matching some conditions and also get cuberoot of field1 in each
record.

Logical query for same will look like:
select *, cuberoot("field1") from index where condition1 and condition2;

Other example:

i have a field "field2" having string value. Now i want to get all
records matching some conditions and also get reverse of field2 in each
record.

Logical query for same will look like:
select *, reverse("field2") from index where condition1 and condition2;

There are some inbuilt mvel functions as mention herehttp://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html#_mvel_built_in_functionsthat can be used within scripts. I want to use some custom function in
similar way of mvel inbuilt functions.

Is it possible to register some custom functions for query ?

Any suggestions would me really helpful.

--
Thanks & Regards
Hanish Bansal

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAB0WE8a3ALbcWgjMXjW9ffQNvggzjBs7nHJLRdvLSd6Btnr%3D5g%40mail.gmail.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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAHO4itznCurPqz9Yv9%3Dtkqt0dKOCGELnZPV1g8fGEsPcAEt2jg%40mail.gmail.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
Thanks & Regards
Hanish Bansal

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAB0WE8YphAFh4_kYBZVyCyeGy1kt0gcjr2Y_%2Bh0vqQsiAvFPGQ%40mail.gmail.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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAHO4ity%3Ds5AGpkA1TfiP9P45ssgRD4Dm9CujnWX_gbo4EPm_hw%40mail.gmail.com
.

For more options, visit https://groups.google.com/groups/opt_out.

--
Thanks & Regards
Hanish Bansal

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAB0WE8Yi%3D2kTBBprDC_euZBPrKHuUEhQpdmmKc9Smm6wVe%2Bj%2Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

You cannot install a Java plugin directly from Github. You would need to
build it yourself (following the instructions) and install the resulting
binary.

--
Ivan

On Mon, Dec 9, 2013 at 6:13 AM, Hanish Bansal <
hanish.bansal.agarwal@gmail.com> wrote:

Hi Jason,

Thanks for sharing the useful links.

I am trying to install sample plugin of native scripts given here
GitHub - imotov/elasticsearch-native-script-example: Example of Now Deprecated Native Script Plugin for Elasticsearch but i am
getting below exception:

    • Installing native-script-example...Failed to install
      native-script-example, reason: no protocol: ../elasticsearch-native-*
      *script-example-master/target/*releases/elasticsearch-native-
      *script-example-1.1.1-SNAPSHOT.*zip

Command used to install plugin is:

bin/plugin -i native-script-example -u
../elasticsearch-native-script-example-master/target/releases/elasticsearch-native-script-example-1.1.1-SNAPSHOT.zip

Name of plugin is "native-script-example" as mentioned in plugin class "
NativeScriptExamplesPlugin".

Please help!!

On Fri, Dec 6, 2013 at 2:44 PM, Jason Wee peichieh@gmail.com wrote:

Hi Hanish,

You have collectively listed steps to perform, why don't try it and see?
if you stumble upon problems, that's when you get to learn really.

To help in your journey, please read the link below, there are a few
example,
GitHub - imotov/elasticsearch-native-script-example: Example of Now Deprecated Native Script Plugin for Elasticsearch
GitHub - imotov/elasticsearch-facet-script: Fully Scriptable Facets for ElasticSearch

Service End for Bintray, JCenter, GoCenter, and ChartCenter | JFrog

http://mgranstrom.com/elasticsearch/2012/10/08/creating-a-native-script-for-elasticsearch.html

That should help in your journey and good luck!

/Jason

On Fri, Dec 6, 2013 at 2:44 PM, Hanish Bansal <
hanish.bansal.agarwal@gmail.com> wrote:

Thanks for response Jason !!

I gone through above links. My understanding is that we will have to do
below thing for this use case:

  1. Create a script in any supported lang. Write a custom function(lets
    say in javascript lang) for reverse a string:

function reverse(s) {
return s.split('').reverse().join('');
}

create a script file for this "reverse.js"

  1. Put this script file into config/scripts

  2. I''ll also need to install javascript lang plugin to support scripts
    written in javascript function.

  3. restart ES if i am using lower version than 0.90.6.

Using this i should be able to use custom function in my query.

Correct me i am missing anything.

Also i am not clear that how to use those functions in query. It would
be really helpful if you could put some examples for same.

On Thu, Dec 5, 2013 at 8:42 PM, Jason Wee peichieh@gmail.com wrote:

Hi Hanish,

Have you read on
Elasticsearch Platform — Find real-time answers at scale | Elastic
?

It should be possible to change to other language other than mvel
Elasticsearch Platform — Find real-time answers at scale | Elastic

These are some supported scripts
Elasticsearch Platform — Find real-time answers at scale | Elastic

HTH

/Jason

On Thu, Dec 5, 2013 at 9:14 PM, Hanish Bansal <
hanish.bansal.agarwal@gmail.com> wrote:

Hi All,

I want to use some custom functions in elastic-search query.

I want to write my own function and use that while searching the
records in elastic-search.

for example:
i have a field "field1" having double value. Now i want to get all
records matching some conditions and also get cuberoot of field1 in each
record.

Logical query for same will look like:
select *, cuberoot("field1") from index where condition1 and
condition2;

Other example:

i have a field "field2" having string value. Now i want to get all
records matching some conditions and also get reverse of field2 in each
record.

Logical query for same will look like:
select *, reverse("field2") from index where condition1 and condition2;

There are some inbuilt mvel functions as mention herehttp://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html#_mvel_built_in_functionsthat can be used within scripts. I want to use some custom function in
similar way of mvel inbuilt functions.

Is it possible to register some custom functions for query ?

Any suggestions would me really helpful.

--
Thanks & Regards
Hanish Bansal

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAB0WE8a3ALbcWgjMXjW9ffQNvggzjBs7nHJLRdvLSd6Btnr%3D5g%40mail.gmail.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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAHO4itznCurPqz9Yv9%3Dtkqt0dKOCGELnZPV1g8fGEsPcAEt2jg%40mail.gmail.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
Thanks & Regards
Hanish Bansal

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAB0WE8YphAFh4_kYBZVyCyeGy1kt0gcjr2Y_%2Bh0vqQsiAvFPGQ%40mail.gmail.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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAHO4ity%3Ds5AGpkA1TfiP9P45ssgRD4Dm9CujnWX_gbo4EPm_hw%40mail.gmail.com
.

For more options, visit https://groups.google.com/groups/opt_out.

--
Thanks & Regards
Hanish Bansal

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAB0WE8Yi%3D2kTBBprDC_euZBPrKHuUEhQpdmmKc9Smm6wVe%2Bj%2Bw%40mail.gmail.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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQBQER0DUigqJv9yYr8vR7eUhj9wDQvAMnJoQzyUDz77dg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

HI lvan,

I build that following instructions using mvn package command and then i
tried to install bundle plugin using install command. I was able to
successfully build it but i was getting error while installing that.

Instructions on shared link
https://github.com/imotov/elasticsearch-native-script-example#creating-elasticsearch-plugin
is:

The plugin can be built using mvn package command. The assembled .zip
package can be found in the target/releases/ directory and deployed to
elasticsearch installation using plugin -install plugin-name -url
path/to/plugin/zip/file.

If i manually copy the extracted zip file into plugin directory of
elasticsearch and make entry of script factory class in elasticsearch.yml
(using script.native.my.type) then i am able to use native scripts. The
error comes only when i install that as plugin.

On Tue, Dec 10, 2013 at 10:42 AM, Ivan Brusic ivan@brusic.com wrote:

You cannot install a Java plugin directly from Github. You would need to
build it yourself (following the instructions) and install the resulting
binary.

--
Ivan

On Mon, Dec 9, 2013 at 6:13 AM, Hanish Bansal <
hanish.bansal.agarwal@gmail.com> wrote:

Hi Jason,

Thanks for sharing the useful links.

I am trying to install sample plugin of native scripts given here
GitHub - imotov/elasticsearch-native-script-example: Example of Now Deprecated Native Script Plugin for Elasticsearch but i am
getting below exception:

    • Installing native-script-example...Failed to install
      native-script-example, reason: no protocol: ../elasticsearch-native-*
      *script-example-master/target/*releases/elasticsearch-native-
      *script-example-1.1.1-SNAPSHOT.*zip

Command used to install plugin is:

bin/plugin -i native-script-example -u
../elasticsearch-native-script-example-master/target/releases/elasticsearch-native-script-example-1.1.1-SNAPSHOT.zip

Name of plugin is "native-script-example" as mentioned in plugin class "
NativeScriptExamplesPlugin".

Please help!!

On Fri, Dec 6, 2013 at 2:44 PM, Jason Wee peichieh@gmail.com wrote:

Hi Hanish,

You have collectively listed steps to perform, why don't try it and see?
if you stumble upon problems, that's when you get to learn really.

To help in your journey, please read the link below, there are a few
example,
GitHub - imotov/elasticsearch-native-script-example: Example of Now Deprecated Native Script Plugin for Elasticsearch
GitHub - imotov/elasticsearch-facet-script: Fully Scriptable Facets for ElasticSearch

Service End for Bintray, JCenter, GoCenter, and ChartCenter | JFrog

http://mgranstrom.com/elasticsearch/2012/10/08/creating-a-native-script-for-elasticsearch.html

That should help in your journey and good luck!

/Jason

On Fri, Dec 6, 2013 at 2:44 PM, Hanish Bansal <
hanish.bansal.agarwal@gmail.com> wrote:

Thanks for response Jason !!

I gone through above links. My understanding is that we will have to do
below thing for this use case:

  1. Create a script in any supported lang. Write a custom function(lets
    say in javascript lang) for reverse a string:

function reverse(s) {
return s.split('').reverse().join('');
}

create a script file for this "reverse.js"

  1. Put this script file into config/scripts

  2. I''ll also need to install javascript lang plugin to support scripts
    written in javascript function.

  3. restart ES if i am using lower version than 0.90.6.

Using this i should be able to use custom function in my query.

Correct me i am missing anything.

Also i am not clear that how to use those functions in query. It would
be really helpful if you could put some examples for same.

On Thu, Dec 5, 2013 at 8:42 PM, Jason Wee peichieh@gmail.com wrote:

Hi Hanish,

Have you read on
Elasticsearch Platform — Find real-time answers at scale | Elastic
?

It should be possible to change to other language other than mvel
Elasticsearch Platform — Find real-time answers at scale | Elastic

These are some supported scripts
Elasticsearch Platform — Find real-time answers at scale | Elastic

HTH

/Jason

On Thu, Dec 5, 2013 at 9:14 PM, Hanish Bansal <
hanish.bansal.agarwal@gmail.com> wrote:

Hi All,

I want to use some custom functions in elastic-search query.

I want to write my own function and use that while searching the
records in elastic-search.

for example:
i have a field "field1" having double value. Now i want to get all
records matching some conditions and also get cuberoot of field1 in each
record.

Logical query for same will look like:
select *, cuberoot("field1") from index where condition1 and
condition2;

Other example:

i have a field "field2" having string value. Now i want to get all
records matching some conditions and also get reverse of field2 in each
record.

Logical query for same will look like:
select *, reverse("field2") from index where condition1 and
condition2;

There are some inbuilt mvel functions as mention herehttp://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html#_mvel_built_in_functionsthat can be used within scripts. I want to use some custom function in
similar way of mvel inbuilt functions.

Is it possible to register some custom functions for query ?

Any suggestions would me really helpful.

--
Thanks & Regards
Hanish Bansal

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAB0WE8a3ALbcWgjMXjW9ffQNvggzjBs7nHJLRdvLSd6Btnr%3D5g%40mail.gmail.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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAHO4itznCurPqz9Yv9%3Dtkqt0dKOCGELnZPV1g8fGEsPcAEt2jg%40mail.gmail.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
Thanks & Regards
Hanish Bansal

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAB0WE8YphAFh4_kYBZVyCyeGy1kt0gcjr2Y_%2Bh0vqQsiAvFPGQ%40mail.gmail.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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAHO4ity%3Ds5AGpkA1TfiP9P45ssgRD4Dm9CujnWX_gbo4EPm_hw%40mail.gmail.com
.

For more options, visit https://groups.google.com/groups/opt_out.

--
Thanks & Regards
Hanish Bansal

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAB0WE8Yi%3D2kTBBprDC_euZBPrKHuUEhQpdmmKc9Smm6wVe%2Bj%2Bw%40mail.gmail.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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQBQER0DUigqJv9yYr8vR7eUhj9wDQvAMnJoQzyUDz77dg%40mail.gmail.com
.

For more options, visit https://groups.google.com/groups/opt_out.

--
Thanks & Regards
Hanish Bansal

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAB0WE8aTV5MnHk_tfoiwouwVjdqXOmtva1NXUkgebH9WMiZusQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

I never really looked at that plugin, the build process is much more
complicated than normal. :slight_smile:

What the bin/plugin script basically does is downloaded the zip file (if
necessary) and unzip it into the correct location in the plugins directory.
What you normally end up with for Java plugins is a subdirectory with
various jar files, including one with an es-plugin.properties file.

If you want to bypass the plugin script, simply unzip the zip file into a
subdirectory inside plugins. There is not much magic involved with plugin
script. Since I have never built that plugin (I should really look into
it), can you sure what the contents of the zip file looks like?

Cheers,

Ivan

On Tue, Dec 10, 2013 at 7:03 PM, Hanish Bansal <
hanish.bansal.agarwal@gmail.com> wrote:

HI lvan,

I build that following instructions using mvn package command and then i
tried to install bundle plugin using install command. I was able to
successfully build it but i was getting error while installing that.

Instructions on shared link
https://github.com/imotov/elasticsearch-native-script-example#creating-elasticsearch-plugin
is:

The plugin can be built using mvn package command. The assembled .zip
package can be found in the target/releases/ directory and deployed to
elasticsearch installation using plugin -install plugin-name -url
path/to/plugin/zip/file.

If i manually copy the extracted zip file into plugin directory of
elasticsearch and make entry of script factory class in elasticsearch.yml
(using script.native.my.type) then i am able to use native scripts. The
error comes only when i install that as plugin.

On Tue, Dec 10, 2013 at 10:42 AM, Ivan Brusic ivan@brusic.com wrote:

You cannot install a Java plugin directly from Github. You would need to
build it yourself (following the instructions) and install the resulting
binary.

--
Ivan

On Mon, Dec 9, 2013 at 6:13 AM, Hanish Bansal <
hanish.bansal.agarwal@gmail.com> wrote:

Hi Jason,

Thanks for sharing the useful links.

I am trying to install sample plugin of native scripts given here
GitHub - imotov/elasticsearch-native-script-example: Example of Now Deprecated Native Script Plugin for Elasticsearch but i am
getting below exception:

    • Installing native-script-example...Failed to install
      native-script-example, reason: no protocol: ../elasticsearch-native-*
      *script-example-master/target/*releases/elasticsearch-native-
      *script-example-1.1.1-SNAPSHOT.*zip

Command used to install plugin is:

bin/plugin -i native-script-example -u
../elasticsearch-native-script-example-master/target/releases/elasticsearch-native-script-example-1.1.1-SNAPSHOT.zip

Name of plugin is "native-script-example" as mentioned in plugin class "
NativeScriptExamplesPlugin".

Please help!!

On Fri, Dec 6, 2013 at 2:44 PM, Jason Wee peichieh@gmail.com wrote:

Hi Hanish,

You have collectively listed steps to perform, why don't try it and
see? if you stumble upon problems, that's when you get to learn really.

To help in your journey, please read the link below, there are a few
example,
GitHub - imotov/elasticsearch-native-script-example: Example of Now Deprecated Native Script Plugin for Elasticsearch
GitHub - imotov/elasticsearch-facet-script: Fully Scriptable Facets for ElasticSearch

Service End for Bintray, JCenter, GoCenter, and ChartCenter | JFrog

http://mgranstrom.com/elasticsearch/2012/10/08/creating-a-native-script-for-elasticsearch.html

That should help in your journey and good luck!

/Jason

On Fri, Dec 6, 2013 at 2:44 PM, Hanish Bansal <
hanish.bansal.agarwal@gmail.com> wrote:

Thanks for response Jason !!

I gone through above links. My understanding is that we will have to
do below thing for this use case:

  1. Create a script in any supported lang. Write a custom
    function(lets say in javascript lang) for reverse a string:

function reverse(s) {
return s.split('').reverse().join('');
}

create a script file for this "reverse.js"

  1. Put this script file into config/scripts

  2. I''ll also need to install javascript lang plugin to support
    scripts written in javascript function.

  3. restart ES if i am using lower version than 0.90.6.

Using this i should be able to use custom function in my query.

Correct me i am missing anything.

Also i am not clear that how to use those functions in query. It would
be really helpful if you could put some examples for same.

On Thu, Dec 5, 2013 at 8:42 PM, Jason Wee peichieh@gmail.com wrote:

Hi Hanish,

Have you read on
Elasticsearch Platform — Find real-time answers at scale | Elastic
?

It should be possible to change to other language other than mvel
Elasticsearch Platform — Find real-time answers at scale | Elastic

These are some supported scripts
Elasticsearch Platform — Find real-time answers at scale | Elastic

HTH

/Jason

On Thu, Dec 5, 2013 at 9:14 PM, Hanish Bansal <
hanish.bansal.agarwal@gmail.com> wrote:

Hi All,

I want to use some custom functions in elastic-search query.

I want to write my own function and use that while searching the
records in elastic-search.

for example:
i have a field "field1" having double value. Now i want to get all
records matching some conditions and also get cuberoot of field1 in each
record.

Logical query for same will look like:
select *, cuberoot("field1") from index where condition1 and
condition2;

Other example:

i have a field "field2" having string value. Now i want to get all
records matching some conditions and also get reverse of field2 in each
record.

Logical query for same will look like:
select *, reverse("field2") from index where condition1 and
condition2;

There are some inbuilt mvel functions as mention herehttp://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html#_mvel_built_in_functionsthat can be used within scripts. I want to use some custom function in
similar way of mvel inbuilt functions.

Is it possible to register some custom functions for query ?

Any suggestions would me really helpful.

--
Thanks & Regards
Hanish Bansal

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAB0WE8a3ALbcWgjMXjW9ffQNvggzjBs7nHJLRdvLSd6Btnr%3D5g%40mail.gmail.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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAHO4itznCurPqz9Yv9%3Dtkqt0dKOCGELnZPV1g8fGEsPcAEt2jg%40mail.gmail.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
Thanks & Regards
Hanish Bansal

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAB0WE8YphAFh4_kYBZVyCyeGy1kt0gcjr2Y_%2Bh0vqQsiAvFPGQ%40mail.gmail.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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAHO4ity%3Ds5AGpkA1TfiP9P45ssgRD4Dm9CujnWX_gbo4EPm_hw%40mail.gmail.com
.

For more options, visit https://groups.google.com/groups/opt_out.

--
Thanks & Regards
Hanish Bansal

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAB0WE8Yi%3D2kTBBprDC_euZBPrKHuUEhQpdmmKc9Smm6wVe%2Bj%2Bw%40mail.gmail.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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQBQER0DUigqJv9yYr8vR7eUhj9wDQvAMnJoQzyUDz77dg%40mail.gmail.com
.

For more options, visit https://groups.google.com/groups/opt_out.

--
Thanks & Regards
Hanish Bansal

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAB0WE8aTV5MnHk_tfoiwouwVjdqXOmtva1NXUkgebH9WMiZusQ%40mail.gmail.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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQAD981_Qr%3DBFeyEAFudSSioGCkRZBWfyoS1%2B3-wqS6A5A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.