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.

Reply via email to