2

我一直在使用 groovy 脚本作为 ScriptType.File。我的 groovy 脚本的一部分看起来像这样。

def refApplicValues =_source.refApplicValue;
def lineNumbers = refApplicValues.tokenize('|');

现在我正在迁移到使用无痛脚本的 ElasticSearch 5.2.1。我已经修改了我的脚本以匹配无痛语法,例如:

def refApplicValues =params._source.refApplicValue;
def lineNumbers = refApplicValues.tokenize('|');

当我现在运行我的脚本时,它会抛出运行时错误:

Caused by: QueryPhaseExecutionException[Query Failed [Failed to execute main query]]; nested: ScriptException[runtime error]; nested: IllegalArgumentException[Unable to find dynamic method [tokenize] with [1] arguments for class [java.lang.String].];
    at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:405)
    at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:106)
    at org.elasticsearch.search.SearchService.loadOrExecuteQueryPhase(SearchService.java:246)
    at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:360)
    at org.elasticsearch.action.search.SearchTransportService$9.messageReceived(SearchTransportService.java:322)
    at org.elasticsearch.action.search.SearchTransportService$9.messageReceived(SearchTransportService.java:319)
    at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69)
    at org.elasticsearch.transport.TransportService$7.doRun(TransportService.java:610)
    at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:596)
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

它告诉我我不能使用 tokenize 。是否有任何相关功能可以替代使用?

4

1 回答 1

1

您可以无痛使用StringTokenizer

于 2017-08-06T19:15:22.237 回答