在es5.5中,如何确定字段是否为数字?
if (is_numeric(ctx._source.some)) {
ctx._source.some = ctx._source.some + 2
}
答案 0 :(得分:0)
instanceof运算符可能会在这里提供帮助
if (ctx._source.some instanceof byte ||
ctx._source.some instanceof short ||
ctx._source.some instanceof int ||
ctx._source.some instanceof long ||
ctx._source.some instanceof float ||
ctx._source.some instanceof double)
{
ctx._source.some = ctx._source.some + 2
}
答案 1 :(得分:0)
另一种方法是使用Traceback (most recent call last):
File "g:/python learning/mysqlconnector.py", line 1, in <module>
import mysql.connector
ModuleNotFoundError: No module named 'mysql'
,请参见https://www.elastic.co/guide/en/elasticsearch/painless/6.8/painless-debugging.html
这将以Debug.explain
终止,并且输出将告诉您所涉及的类。有了这些信息(可以从各个ElasticSearch版本的各个索引中手动获得),然后可以使用painless_explain_error
实现Painless,如@ oleg-grishko的答案所示。
instanceof