Is there a way to negate a solr surround query? I'm using it in a fq field, if that gives me more options for negating the results.
fq={!surround}fieldName:2w(foo,bar)
I normally negate a filter by prepending '-', e.g.,
fq=-fieldName:baz
But when you do this with the surround query you get an error:
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> ...
")" ...
"," ...
"^" ...
Okay, so maybe '-' is not allowed and you can't have a lonely NOT. This works:
q={!surround}AND(fieldName:2w(foo,bar),otherField:baz)
but this fails
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> ...