solr查询语法的潜在语法错误列表?

solr查询语法的潜在语法错误列表?,solr,syntax-error,Solr,Syntax Error,我想看看solr是否有一个完整的语法错误列表。我的目标是创建一个“清理”前端用户查询的函数,这样它就不会导致语法错误 到目前为止,我发现了两个错误: EOF 如果查询以大写的AND、OR、NOT等结尾,则抛出EOF错误。 修复:小写查询(因为查询设置为不区分大小写) 不明字段信息 如果查询包含冒号,如“长学术标题的开始:此处的诙谐副标题”。 修复:用空格替换:的所有实例 我希望这就是我需要解决的所有问题,但是如果有任何其他solr语法错误我应该注意并控制,那将非常有用 我不确定是否有语法错误的全

我想看看solr是否有一个完整的语法错误列表。我的目标是创建一个“清理”前端用户查询的函数,这样它就不会导致语法错误

到目前为止,我发现了两个错误:

EOF 如果查询以大写的AND、OR、NOT等结尾,则抛出EOF错误。
修复:小写查询(因为查询设置为不区分大小写)

不明字段信息 如果查询包含冒号,如“长学术标题的开始:此处的诙谐副标题”。
修复:用空格替换
的所有实例


我希望这就是我需要解决的所有问题,但是如果有任何其他solr语法错误我应该注意并控制,那将非常有用

我不确定是否有语法错误的全面列表,但以下是我们处理的一些错误:

1) encoding issues: special characters like %, & etc should not be
passed as it is as they may ruin the whole query

2) cases of two asterisks together: ** may cause infinite loops or
put the system down to its knees, if leading and trailing wildcards
are accepted. Case when a search term is just one asterisk isn't
allowed in our system either

3) (optionally) for boolean queries ensure that opening and closing
brackets match

4) strip the punctuation, but do it with care, e.g. if U.S. turns
into US, then to ensure findability (recall matters to us), we make
sure same happens during the tokenization. Also we identify urls and
don't remove punctuation from them

5) some errors may relate to malformed proximity operators (like
near, ~), e.g. we don't allow them to be nested or boolean operators
inside them
我还要说,一些语法错误可以通过您为用户定义的语法来控制。那就是不允许他们做你不想让他们做的事。这也会在用户和应用程序之间形成某种搜索契约。提供一些类似工具提示的信息也很好,这些信息将告诉用户什么典型语法可以用于什么目的