Reputation: 61
Hi I have a string field which can be empty\null for certain documents. I like to know how to search for those documents.
I want to know thru searchquery and not ODatFilter as I may like to solve following cases:
So ODataFilter suggestions will not help in achieving #2 so #1 should be using searchQuery.
Any help is appreciated.
Upvotes: 6
Views: 7920
Reputation: 8634
You can actually combine OData filters with search queries using the search.ismatch
or search.ismatchscoring
functions. These functions let you embed full-text search queries inside a filter, which would allow you to address all your scenarios:
$filter=A ne null
$filter=A ne null and search.ismatchscoring('A:test', null, 'full', null)
or equivalently, $filter=A ne null&search=A:test&queryType=full
$filter=A eq null or search.ismatchscoring('A:test', null, 'full', null)
-- this can only be achieved with filters and search.ismatch
/search.ismatchscoring
because of the "or" operator.The filter A ne null
in case 2 above is actually redundant since nulls won't match any full-text search query, but in case 3 where you want to match nulls, filters are the way to do it.
Upvotes: 7