我正在进行一个项目,目的是建立一个检索生物医学信息的系统(例如,生物医学实体,如药物、疾病和基因,以及它们之间的关系)。当我试图检索数据库以使用cypher语句查找特定疾病时:
用于密码字符串MATCH (m:Disease) WHERE m.disease_name =~ '(?i)"+disease+"' RETURN m
;
如果该疾病的名称为2'-benzoyloxycinnamaldehyde
或4-[1-ALLYL-7-(TRIFLUOROMETHYL)-1H-INDAZOL-3-YL]BENZENE-1,3-DIOL
,将出现以下消息的例外情况:
无效输入‘:预期0.9,'.','E','e',标识符,空格,节点标签,'[',"=~",IN,开始,结束,包含,IS,'^','*','/',’‘,'%','+',’,'=‘’,‘’=‘’,‘<>’,‘’,‘,"<=",">=",以及,XOR,OR,LOAD CSV,开始,匹配,解除,合并,创建,设置,删除,删除,FOREACH,与,返回,联合,';‘或输入结束(第1行,第53栏(偏移: 52))“匹配( n1 :药物)-x-(N2:疾病)返回n1限制25”
我怎么才能解决这个问题?非常感谢!
发布于 2016-02-09 16:57:42
实际上有两个不同的查询,它们有不同的问题:
disease
值包含单引号,那么这将过早结束regexp。您有几种选择,列在“提高质量”中:- Escape (using a preceding backslash) all single-quote characters in `disease`.
- Use double-quotes as the regexp string delimiter (which requires escape characters as well, but `disease` does not need to be changed). I am presuming that `disease` (which actually seems to be a chemical name) will never include a double-quote:
"MATCH (m: disease )其中m.disease_name =~ \"(?i)“+disease+”\“返回m";
-将disease
值作为参数传递。没有转义是必要的,如果您需要多次进行本质上相同的查询,则查询将更快。然而,传入的参数值必须以"(?i)“开头。
“匹配(m:疾病)其中m.disease_name =~ {disease}返回m";
https://stackoverflow.com/questions/35285080
复制相似问题