On 8/21/2015 8:34 AM, Brian Narsi wrote:
> CustomerID is a string
> CustomerName is text
>
> I have a query like this (i.e. (CustomerID is NULL or CustomerID = 56789)
> and (CustomerName like smith)):

Note that you must leave the default operator as "OR" for +/- syntax to
work as intended.  It will not work the way most people expect if the
default operator is AND.

The +/- way to express this query is as follows:

+((*:* -CustomerID:[* TO *]) CustomerID:56789) +CustomerName:smith


Note that both of the outer clauses in this query (stuff in parentheses
is a single clause, even if that clause itself is composed of multiple
clauses) have a + on them, making them both MUST clauses.

This query can be simplified to the following, because a "not null"
query will also match a search for a specific value:

+(*:* -CustomerID:[* TO *]) +CustomerName:smith

If you need "smith" to also match "Hammersmiths" then you would need to
put asterisks before and after smith, or use ngram analysis on the
CustomerName field.  A wildcard search is almost always significantly
slower than a search on an ngrammed field.

Thanks,
Shawn

Reply via email to