Hi,
I'm trying to cache script results using
cache = CacheBuilder.newBuilder()
> .maximumSize(CACHE_MAX_SIZE)
> .recordStats()
> .build();
then in the script I have
@Override
> public Integer run() {
> try {
> return cache.get(getCacheKey(), callable);
> } catch (ExecutionException e) {
> throw new ScriptException(e.getMessage(), e);
> }
> }
and the callable is:
new Callable<Integer>() {
> @Override
> public Integer call() throws Exception {
> return getCalculatedResult();
> }
> };
Could you please help me to create a proper cache key? I want to keep
unique results for each document/index. As I understand, cache is shared
between multiple indices, so I need to put it in the cache key.
Questions:
1. What should I use to identify the document? Can I use
indexLookup().getDocId()? Or I should use docFieldLongs("id").getValue() (I
have this field in documents)? Can I access "_id" property?
2. Can I get the index/type during script execution?
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/474ad09b-3800-4bd0-a50a-97bfd6d9086e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.