首页 > > > solr查询特殊字符的处理
1. 使用solr的页面功能时,遇到语法错误

2. 确认原因
从lexical error分析时特殊字符的问题。
首先 solr查询有哪些特殊字符?
查找官方文档:http://lucene.apache.org/core/7_6_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package.description
Lucene supports escaping special characters that are part of the query syntax. The current list special characters are
+ - && || ! ( ) { } [ ] ^ " ~ * ? : \ /
双引号包含在内,故确认原因。
3.解决方式
官方提供了解决方式http://lucene.apache.org/core/7_6_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package.description
To escape these character use the \ before the character. For example to search for (1+1):2 use the query:
\(1\+1\)\:2
4.验证问题

问题解决
5.小结
特殊字符的处理在java solr都会存在,官方文档作为最权威的数据来源,值得我们关注。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2730/viewspace-3159537/ ,如需转载,请注明出处,否则将追究法律责任。