Re: Duplicate function MVEL script
The problem with MVEL that you can't redefine defined function in a script instance. Script class instantiates once the query starts, and then it's executing it again and again. MVEL is bad for complex scripting. Yes, you could use groovy,and should :) I found a good way to use it with the next code: *import* groovy.lang.Script *class* MyScript *extends* Script { *def* run() { // your code is here, also binded variables should be available here } } So how it works: 1. Groovy compiles this script and put to class cache. 2. One each query MyScript instance is created (on per node) 3. On each document run() method is executed (It should provide different return values for filter script, score script, sort script, script fields) Alex On Wednesday, August 27, 2014 5:50:11 PM UTC+3, k...@stylelabs.com wrote: Hello We are executing some concurrent updates on the same document using an MVEL script together with some parameters. The MVEL script contains some functions such as addRelations etc but there is no sign of duplicate functions. ES throws the following error: [John Kafka][inet[/10.12.1.219:9300]][update]]; nested: ElasticsearchIllegalArgumentException[failed to execute script]; nested: *CompileException*[[Error: *duplicate function: addRelations*] [Near : {... def addRelations(relationNode, }] ^ [Line: 1, Column: 1] ES Version 1.3.2 If the updates are executed sequentially there is no error/problem with the MVEL script. Any idea's? Best Regards, Kristof -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e549c53b-90ae-41ca-b106-5c6e812417f7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: groovy for scripting
providing self-update: I found that I could create cross-request cache using next script (like a cross-request incrementer): POST /test/_search { query: {match_all:{}}, script_fields: { a: { script: import groovy.lang.Script;class A extends Script{static i=0;def run() {i++}}, lang: groovy } } } In good view mode the script is: import groovy.lang.Script class A extends Script{ static i=0 def run() { i++ } } Actually here *i* variable is not thread-safe, but idea is clean - you need define a class, inherited from Script and implement abstract method run. Also this class is access on each node-thread. Now I'm looking for a solution to make a query-scope type counter (for one-node configuration). I think it's could be done by passing unique query_id in parameters, but I'm afraid of making code non thread safe, or vice versa - thread safe, but with reduce performance. Researching more... -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/fb402d2c-8820-4a1f-99e0-0453c0c82cf6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
groovy for scripting
I'm playing around with groovy scripting. By checking groovy lang plugin source code I found next steps in code execution: 1. Code compilation into script class 2. Script initialization via static method newInstance() 3. Script execution via calling the code on each document with binding document parameters Now assume I have class declaration in my script. Is it possible to execute class definition and class object initialization only once, and execute only a method from this object on each document? Thanks P.S. posting the same on SO -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/bb3a9ca6-79fd-4ac6-ac78-ce0c102b9505%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
LookupScript per shard modification (native scripting)
Hi, I'm trying LookupScript example here: https://github.com/imotov/elasticsearch-native-script-example/blob/master/src/main/java/org/elasticsearch/examples/nativescript/script/LookupScript.java The idea of my script is to pre-cache all child documents in LookupScript instance, but I want to query only current shard data. Is it possible? So every shard instance caches only it's documents. Regards, Alex -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/bada48a1-7b74-41a0-81a9-564b5061b605%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Cosine Similarity ElasticSearch
Hi, I found some native script codings from Igor Motov here: https://github.com/imotov/elasticsearch-native-script-example/blob/master/src/main/java/org/elasticsearch/examples/nativescript/script/CosineSimilarityScoreScript.java and now playing with it Alex On Friday, August 1, 2014 11:53:24 AM UTC+3, Federico Bianchi wrote: There is someone that can help us? Thank you very much! -- View this message in context: http://elasticsearch-users.115913.n3.nabble.com/Cosine-Similarity-ElasticSearch-tp4060620p4061039.html Sent from the ElasticSearch Users mailing list archive at Nabble.com. -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/5b9025dd-0173-4b09-ae09-31a2f78e99d7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
3rd party scoring service
Hello, My idea is to use 3rd party scoring service (REST), and currently I'd like to use native scripts and play with NativeScriptFactory. The approach has many drawbacks. Here is my problem - assume we have two entities - products and product prices. I should filter by price. Price is a complex thing, because it depends on many factors, like request date, remote user information, custom provided parameters. In case of regular parent - child relation and has_child query it's too complex and too slow to implement it using scripting (currently mvel). Also one more condition - i have not many products - around 25K, and around 25M different base price items (which are basic for future price calculation). There are next ideas: 1. Have a service, which returns exact price for all product by custom parameters like. The drawback is - there should be 5 same calls from each shard (if 5 by default). In this case it doesn't matter, where base prices are stored - in elasticsearch index, in database or in in-memory storage. 2. Write a code, which operates over child price documents on concrete shard. In this case it will generate prices only for all properties from particular shard. But I don't know, if I can access shard index or make calls to the index from concrete shard in NativeScriptFactory class. Could you point me the right way? P.S. Initially I was interested in Redis-Elasticsearch example http://java.dzone.com/articles/connecting-redis-elasticsearch Thanks, Alex -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/893b22dc-1415-475b-8675-596119f4f1f8%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: 3rd party scoring service
I think it's acceptable if service responds with 20ms and using some thrift protocol for example. It's much better then current 500ms - 5s calculations using elasticsearch scripting. If we have 25K products than it could be around 300Kb data package from this service. The risk is in possible broken communication or some increased latency Alex On Thursday, July 31, 2014 1:59:36 PM UTC+3, Itamar Syn-Hershko wrote: You should bring the price over to Elasticsearch and not the other way around. Scoring against an external service is an added friction with huge performance costs. -- Itamar Syn-Hershko http://code972.com | @synhershko https://twitter.com/synhershko Freelance Developer Consultant Author of RavenDB in Action http://manning.com/synhershko/ On Thu, Jul 31, 2014 at 1:50 PM, Alex S.V. alexs.v...@gmail.com javascript: wrote: Hello, My idea is to use 3rd party scoring service (REST), and currently I'd like to use native scripts and play with NativeScriptFactory. The approach has many drawbacks. Here is my problem - assume we have two entities - products and product prices. I should filter by price. Price is a complex thing, because it depends on many factors, like request date, remote user information, custom provided parameters. In case of regular parent - child relation and has_child query it's too complex and too slow to implement it using scripting (currently mvel). Also one more condition - i have not many products - around 25K, and around 25M different base price items (which are basic for future price calculation). There are next ideas: 1. Have a service, which returns exact price for all product by custom parameters like. The drawback is - there should be 5 same calls from each shard (if 5 by default). In this case it doesn't matter, where base prices are stored - in elasticsearch index, in database or in in-memory storage. 2. Write a code, which operates over child price documents on concrete shard. In this case it will generate prices only for all properties from particular shard. But I don't know, if I can access shard index or make calls to the index from concrete shard in NativeScriptFactory class. Could you point me the right way? P.S. Initially I was interested in Redis-Elasticsearch example http://java.dzone.com/articles/connecting-redis-elasticsearch Thanks, Alex -- 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 elasticsearc...@googlegroups.com javascript:. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/893b22dc-1415-475b-8675-596119f4f1f8%40googlegroups.com https://groups.google.com/d/msgid/elasticsearch/893b22dc-1415-475b-8675-596119f4f1f8%40googlegroups.com?utm_medium=emailutm_source=footer . For more options, visit https://groups.google.com/d/optout. -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/c61f9637-3de8-4906-a2c4-49055dee2cd5%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
elasticsearch dynamic scripting vs static script - deployment
Hi, We've been also hacked on our staging server because of opened ports :) I find dynamic scripting flexible for applications, but static scripting causes bunch of problems: 1. I should deploy it in special directory at elasticsearch node? We are using capistrano for web-app deployment and it's easy procedure, though we should provide additional access to elasticsearch node filesystem 2. I don't know, how to support script versions? just append _v1, _v2, etc. suffixes in filename? 3. Should I deploy on one node, or on each node? If I must deploy on each node - what happens if one node has a script, and other doesn't have? Regards, Alex -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/20681e2f-bb8b-4602-8b19-ed27b661a88b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.