有没有办法否定 solr 环绕查询?我在 fq 字段中使用它,如果这给了我更多否定结果的选项。
fq={!surround}fieldName:2w(foo,bar)
我通常通过在前面加上“-”来否定过滤器,例如,
fq=-fieldName:baz
但是,当您使用环绕查询执行此操作时,您会收到错误:
fq=-{!surround}fieldName:2w(foo,bar)
org.apache.solr.search.SyntaxError: org.apache.lucene.queryparser.surround.parser.ParseException: Encountered "<EOF>" at line 1, column 24.
Was expecting one of:
<OR> ...
<AND> ...
<NOT> ...
<W> ...
<N> ...
")" ...
"," ...
"^" ...
好的,所以也许“-”是不允许的,你不能有一个孤独的 NOT。这有效:
q={!surround}AND(fieldName:2w(foo,bar),otherField:baz)
但这失败了
q={!surround}AND(NOT(fieldName:2w(foo,bar)),otherField:baz)
org.apache.solr.search.SyntaxError: org.apache.lucene.queryparser.surround.parser.ParseException: Encountered " <NOT> "NOT "" at line 1, column 4.
Was expecting one of:
<OR> ...
<AND> ...
<W> ...
<N> ...
"(" ...
<TRUNCQUOTED> ...
<QUOTED> ...
<SUFFIXTERM> ...
<TRUNCTERM> ...
<TERM> ...