是时候用 ES 拯救发际线啦

ES调用script 奇怪错误

Elasticsearch | 作者 jiakechong1642 | 发布于2017年06月01日 | 阅读数:3185

1.软件环境
ES2.3
2.问题简述
我已经打开了ES的脚本,在sense插件中输入查询(带有groovy脚本)可以运行,但是同样的查询体,用命令行 curl  进行操作确返回脚本异常
如下图
这是在sense中进行的查询,可以正常使用
屏幕快照_2017-06-01_16.37_.47_.png

这是使用命令行返回的查询结果,返回脚本异常(所用命令行在下面)
屏幕快照_2017-06-01_16.38_.11_.png

那前辈会说,是不是你的命令行写的有错呢?以前我都是这样,先在sense中调试,然后在curl命令行中调用,查询语句命令行的写法应该没有问题,而且也参考了官方文档
------------------------------------------------------------------------------------
命令行如下
curl -XGET 'http://xxxxx/qmp_search_bm25/product_comp_tags_all/_search?preference="sh345"' -d '{"query": {"function_score": {"query": {"match": {"product": "\u6ef4\u6ef4"}}, "script_score": {"script": {"lang": "groovy", "params": {"threshold1": 0, "threshold2": 15, "param2": 2, "param1": 2.5}, "file": "category-score"}}, "boost_mode": "multiply"}}, "min_score": 0.3, "from": 0, "size": 20}'

 
 
所以我就奇怪了,为什么一用命令行就出问题了呢?是不是有什么权限问题呢?

 
 
已邀请:

Ricky_Lau - 码农,,

赞同来自:

1. 命令如下
    curl -XGET 'http://47.93.119.68:9200/qmp_search_bm25/product_comp_tags_all/_search?pretty&preference="sh345"' -d '{"query": {"function_score": {"query": {"match": {"product": "\u6ef4\u6ef4"}}, "script_score": {"script": {"lang": "groovy", "params": {"threshold1": 0, "threshold2": 15, "param2": 2, "param1": 2.5}, "file": "category-score"}}, "boost_mode": "multiply"}}, "min_score": 0.3, "from": 0, "size": 20}' > result 

 结果见附件,应该是你的环境有问题。


 

kennywu76 - Wood

赞同来自:

仔细看,sense里搜索的索引名称和curl里搜索的不一样, 先确定两次测试搜的是同一个索引!

要回复问题请先登录注册