Scripts during indexing


(Adrian-2) #1

Hi all,

I wonder if it is possible to use scripts within an index statement?

Thanks, Adrian

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(Adrian-2) #2

On Thu, Sep 05, 2013 at 08:08:30AM +0000, Adrian wrote:

All,

I wonder if it is possible to use scripts within an index statement?

In my scripts, I'd like to perform comparison on fields which are mapped as
"date". Given the documentation, these types are json strings, but handled as
Java long types internally. Using MVEL as scripting, I've found operators for
value comparison. Can someone tell on which types (String vs. long) this
comparison is performed?

Thanks, Adrian

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(Luca Cavanna) #3

Hi,
I don't think you can use scripting while indexing. Scripting is more meant
to on-the-fly generate content that you don't have when retrieving docs,
for instance when searching, faceting etc.

Regarding the type question, it depends on where you load the value from.
Have a look here:
http://www.elasticsearch.org/guide/reference/modules/scripting/. If you
load it from disk, using the _source syntax, then it's going to be a
string, like in the json. If you load it from the document fields (field
data), it's going to be a long.

Cheers
Luca

On Thursday, September 5, 2013 11:55:41 AM UTC+2, Adrian wrote:

On Thu, Sep 05, 2013 at 08:08:30AM +0000, Adrian wrote:

All,

I wonder if it is possible to use scripts within an index statement?

In my scripts, I'd like to perform comparison on fields which are mapped
as
"date". Given the documentation, these types are json strings, but handled
as
Java long types internally. Using MVEL as scripting, I've found operators
for
value comparison. Can someone tell on which types (String vs. long) this
comparison is performed?

Thanks, Adrian

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(Adrian-2) #4

On Thu, Sep 05, 2013 at 08:09:53AM -0700, Luca Cavanna wrote:

Luca,

Regarding the type question, it depends on where you load the value from.
Have a look here:
http://www.elasticsearch.org/guide/reference/modules/scripting/. If you
load it from disk, using the _source syntax, then it's going to be a
string, like in the json. If you load it from the document fields (field
data), it's going to be a long.

So, referencing the date field in an update (using ctx._source.) the
comparison operators "<,>" should suffice.

Best, Adrian

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(Ivan Brusic) #5

Scripting is meant to be used during querying time. What are you looking to
achieve? If you are looking at changing the content that is indexed, you
can perhaps use a custom filter/tokenizer/analyzer or modify the data at
the client (index) side.

Cheers,

Ivan

On Thu, Sep 5, 2013 at 1:08 AM, Adrian google@core.kyubu.de wrote:

Hi all,

I wonder if it is possible to use scripts within an index statement?

Thanks, Adrian

--
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.
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.
For more options, visit https://groups.google.com/groups/opt_out.


(Adrian-2) #6

On Thu, Sep 05, 2013 at 11:00:33AM -0700, Ivan Brusic wrote:

Ivan,

Scripting is meant to be used during querying time. What are you looking to
achieve? If you are looking at changing the content that is indexed, you
can perhaps use a custom filter/tokenizer/analyzer or modify the data at
the client (index) side.

I have a quite huge number of documents (> 2 Bio.). When doing an overview of
these using facets on a certain field, the querying time is just too long. So I
tried to build a second index, holding this (aggregated) data. The scripting
was intented to update th relvant fields for this index (such as first seen,
last seen, etc.)

Best regards, Adrian

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #7