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都会存在,官方文档作为最权威的数据来源,值得我们关注。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM