即使用“引号”括起来,短语中的特殊字符也会生成错误

时间:2017-09-27 05:16:08

标签: linux elasticsearch

我有以下代码:

curl -X GET http://localhost:9200/INDEXED REPOSITORY/_search -d '{"query": {"constant_score": {"filter" : {"terms" : {"description" : ["adam attack stokes","adam stokes attacks","adam-stokes attacks","adam-stokes syndrome","adams attack stoke","adams stoke syndrome","adams stokes attack","adams stokes syndrome","adams-stokes","adams-stokes syndrome","adams-stokes; attack","attack; adams-stokes","attack; stokes-adams","attacks adam-stokes","attacks stokes-adams","morgagni\s disease","morgagni-adam\s stokes syndrome","morgagni-stokes-adams","spens\ syndrome","stoke adams syndrome","stokes adams attack","stokes adams attacks","stokes adams syndrome","stokes-adams","stokes-adams attack","stokes-adams attacks","stokes-adams syndrome","stokes-adams-morgagni syndrome","stokes-adams; attack","syndrome adams-stokes","syndrome stokes-adams","syndrome adams-stokes","syndrome stokes-adams","3-12 anginal syndromes","angina","angina of effort","angina pain","angina pectoris","angina syndrome","angina cardiac","anginal discomfort","anginal pain","anginal syndrome","anginal syndromes","anginal; syndrome","anginas","angor pectoris","ap - angina pectoris","cardiac angina","cardio/pulm: angina","chest pain - cardiac","chest pain ischemic","chest; pain ischemic","ischaemic chest pain","ischaemic heart disease - angina","ischaemic ht dis - angina","ischemic chest pain","ischemic heart disease - angina","ischemic ht dis - angina","pain angina","pain; chest ischemic","pectoris angina","stenocardia","stenocardias","syndrome; anginal","angina pectoris variant","angina pectoris; variant","angina prinzmetal","angina variant","angina variant <prinzmetal>","angina variant prinzmetal","angina prinzmetal","angina prinzmetal\s","coronary artery spasm angina","prinzmetal angina","prinzmetal variant angina","prinzmetal\s angina","prinzmetal; angina","prinzmetals angina","variant angina","variant angina pectoris","variant; angina","vasospastic angina","angina at rest","angina pectori unstable","angina pectoris unstable","angina pectoris unstable","angina pectoris; at rest","angina pectoris; crescendo","angina pectoris; unstable","angina unstable","angina preinfarction","angina unstable","anginal chest pain at rest","anginas preinfarction","anginas unstable","coronary; syndrome","crescendo angina","crescendo angina pectoris","crescendo; angina","impending infarction","intermed coronary synd","intermediate coronary syndrome","intermediate coronary; syndrome","myocardial ischemia impending infarction","pre-infarction syndrome","preinfarction angina","preinfarction anginas","preinfarctional; angina","rest angina","rest; angina","syndrome; coronary","syndrome; intermediate coronary","unstable angina","unstable angina pectori","unstable angina pectoris","unstable anginas","unstable; angina","worsening angina","aortic stenosis supra valvular","aortic stenosis supravalv","aortic stenosis supravalvar","aortic stenosis supravalvular","aortic supravalv stenosis","aortic supravalvular stenoses","aortic supravalvular stenosis","stenoses aortic supravalvular","stenosis aortic supravalvular","stenosis supravalvular aortic","supra-aortic stenosis","supra-valvular aortic stenosis","supravalv aortic stenosis","supravalvar aortic stenosis","supravalvular aorta constricted","supravalvular aortic stenosis","supravalvular stenoses aortic","supravalvular stenosis aortic","svas","svas - supravalvar aortic stenosis","ai - aortic incompetence","aorta; incompetency","aorta; insufficiency","aortic (valve) insufficiency","aortic incompetence","aortic insufficiency","aortic regurgitation","aortic valve incompetence","aortic valve insufficiency","aortic valve regurgitation","aortic valve incompetence","aortic valve insufficiency","aortic valve regurgitation","aortic valve; incompetency","aortic valve; insufficiency","aortic valve; regurgitation","ar - aortic regurgitation","incompetence aortic","incompetence aortic valve","incompetency; aortic valve","insufficiency aortic valve","insufficiency; aortic","regurgitation aortic","r"]}}}}}'

我的目标是获取包含任何这些关键字的唯一记录的数量。有2,3个关键字,它工作正常。 但是通过这个关键字列表,我首先看到了这个错误:

-bash: syntax error near unexpected token `valve'

然后,我看到了这个错误:

{"error":"SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[6hWIW7xlSbSqKi4dNg_1bg][INDEXED REPOSITORY][0]: SearchParseException[[INDEXED REPOSITORY][0]: from[-1],size[-1]: Parse Failure [Failed to parse source ......

另外,我必须提到关键字的格式已更改为:

 .....\"angina pectoris; crescendo\",\"angina pectoris; unstable\",\"angina unstable\",\"angina preinfarction\",\"angina unstable\",\"anginal chest pain at rest\",\"anginas preinfarction\",\"anginas unstable\",\"coronary; syndrome\",\"crescendo angina\",\"crescendo angina pectoris\",\"crescendo; angina\"

是否因为“主动脉瓣不能”中的半结肠等特殊字符?但我希望能够进行不敏感,完全匹配搜索。 知道为什么会这样吗? 我真的很感谢你的帮助。

1 个答案:

答案 0 :(得分:0)

归功于@Val。他说:问题来自于morgagni病,你需要在你的条件下正确地逃避反斜杠。