OData full-text search functions in Azure Cognitive Search -
Azure Cognitive Search supports full-text search in the context of OData filter expressions via the
search.ismatchscoring functions. These functions allow you to combine full-text search with strict Boolean filtering in ways that are not possible just by using the top-level
search parameter of the Search API.
The following EBNF (Extended Backus-Naur Form) defines the grammar of the
search_is_match_call ::= 'search.ismatch'('scoring')?'(' search_is_match_parameters ')' search_is_match_parameters ::= string_literal(',' string_literal(',' query_type ',' search_mode)?)? query_type ::= "'full'" | "'simple'" search_mode ::= "'any'" | "'all'"
An interactive syntax diagram is also available:
See OData expression syntax reference for Azure Cognitive Search for the complete EBNF.
search.ismatch function evaluates a full-text search query as a part of a filter expression. The documents that match the search query will be returned in the result set. The following overloads of this function are available:
search.ismatch(search, searchFields, queryType, searchMode)
The parameters are defined in the following table:
||The search query (in either simple or full Lucene query syntax).|
||Comma-separated list of searchable fields to search in; defaults to all searchable fields in the index. When using fielded search in the
All the above parameters are equivalent to the corresponding search request parameters in the Search API.
search.ismatch function returns a value of type
Edm.Boolean, which allows you to compose it with other filter sub-expressions using the Boolean logical operators.
Azure Cognitive Search does not support using
search.ismatchscoring inside lambda expressions. This means it is not possible to write filters over collections of objects that can correlate full-text search matches with strict filter matches on the same object. For more details on this limitation as well as examples, see Troubleshooting collection filters in Azure Cognitive Search. For more in-depth information on why this limitation exists, see Understanding collection filters in Azure Cognitive Search.
search.ismatchscoring function, like the
search.ismatch function, returns
true for documents that match the full-text search query passed as a parameter. The difference between them is that the relevance score of documents matching the
search.ismatchscoring query will contribute to the overall document score, while in the case of
search.ismatch, the document score won't be changed. The following overloads of this function are available with parameters identical to those of
search.ismatchscoring(search, searchFields, queryType, searchMode)
search.ismatchscoring functions can be used in the same filter expression.
Find documents with the word "waterfront". This filter query is identical to a search request with
Find documents with the word "hostel" and rating greater or equal to 4, or documents with the word "motel" and rating equal to 5. Note, this request could not be expressed without the
search.ismatchscoring('hostel') and Rating ge 4 or search.ismatchscoring('motel') and Rating eq 5
Find documents without the word "luxury".
Find documents with the phrase "ocean view" or rating equal to 5. The
search.ismatchscoring query will be executed only against fields
Documents that matched only the second clause of the disjunction will be returned too -- hotels with
Rating equal to 5. To make it clear that those documents didn't match any of the scored parts of the expression, they will be returned with score equal to zero.
search.ismatchscoring('"ocean view"', 'Rooms/Description,HotelName') or Rating eq 5
Find documents where the terms "hotel" and "airport" are within 5 words from each other in the description of the hotel, and where smoking is not allowed in at least some of the rooms. This query uses the full Lucene query language.
search.ismatch('"hotel airport"~5', 'Description', 'full', 'any') and Rooms/any(room: not room/SmokingAllowed)