You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# OData full-text search functions in Azure AI Search - `search.ismatch` and `search.ismatchscoring`
27
17
28
-
Azure AI Search supports full-text search in the context of [OData filter expressions](query-odata-filter-orderby-syntax.md) via the `search.ismatch` and `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](/rest/api/searchservice/documents/search-post).
18
+
Azure AI Search supports full-text search in the context of [OData filter expressions](query-odata-filter-orderby-syntax.md) via the `search.ismatch` and `search.ismatchscoring` functions. These functions allow you to combine full-text search with strict Boolean filtering in ways that aren't possible just by using the top-level `search` parameter of the [Search API](/rest/api/searchservice/documents/search-post).
29
19
30
20
> [!NOTE]
31
-
> The `search.ismatch` and `search.ismatchscoring` functions are only supported in filters in the [Search API](/rest/api/searchservice/documents/search-post). They are not supported in the [Suggest](/rest/api/searchservice/documents/suggest-post) or [Autocomplete](/rest/api/searchservice/documents/autocomplete-post) APIs.
21
+
> The `search.ismatch` and `search.ismatchscoring` functions are only supported in filters in the [Search API](/rest/api/searchservice/documents/search-post). They aren't supported in the [Suggest](/rest/api/searchservice/documents/suggest-post) or [Autocomplete](/rest/api/searchservice/documents/autocomplete-post) APIs.
32
22
33
23
## Syntax
34
24
@@ -58,7 +48,7 @@ An interactive syntax diagram is also available:
58
48
59
49
### search.ismatch
60
50
61
-
The `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:
51
+
The `search.ismatch` function evaluates a full-text search query as a part of a filter expression. Matching documents are returned in the result set. The following overloads of this function are available:
62
52
63
53
-`search.ismatch(search)`
64
54
-`search.ismatch(search, searchFields)`
@@ -69,21 +59,21 @@ The parameters are defined in the following table:
69
59
| Parameter name | Type | Description |
70
60
| --- | --- | --- |
71
61
|`search`|`Edm.String`| The search query (in either [simple](query-simple-syntax.md) or [full](query-lucene-syntax.md) Lucene query syntax). |
72
-
|`searchFields`|`Edm.String`| Comma-separated list of searchable fields to search in; defaults to all searchable fields in the index. When using[fielded search](query-lucene-syntax.md#bkmk_fields) in the `search` parameter, the field specifiers in the Lucene query override any fields specified in this parameter. |
62
+
|`searchFields`|`Edm.String`| Comma-separated list of searchable fields to search in; defaults to all searchable fields in the index. When you use[fielded search](query-lucene-syntax.md#bkmk_fields) in the `search` parameter, the field specifiers in the Lucene query override any fields specified in this parameter. |
73
63
|`queryType`|`Edm.String`|`'simple'` or `'full'`; defaults to `'simple'`. Specifies what query language was used in the `search` parameter. |
74
-
|`searchMode`|`Edm.String`|`'any'` or `'all'`, defaults to `'any'`. Indicates whether any or all of the search terms in the `search` parameter must be matched in order to count the document as a match. When using the [Lucene Boolean operators](query-lucene-syntax.md#bkmk_boolean) in the `search` parameter, they will take precedence over this parameter. |
64
+
|`searchMode`|`Edm.String`|`'any'` or `'all'`, defaults to `'any'`. Indicates whether any or all of the search terms in the `search` parameter must be matched in order to count the document as a match. When you use the [Lucene Boolean operators](query-lucene-syntax.md#bkmk_boolean) in the `search` parameter, they take precedence over this parameter. |
75
65
76
66
All the above parameters are equivalent to the corresponding [search request parameters in the Search API](/rest/api/searchservice/documents/search-post).
77
67
78
-
The `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](search-query-odata-logical-operators.md).
68
+
The `search.ismatch` function returns a value of type `Edm.Boolean`, which allows you to compose it with other filter subexpressions using the Boolean [logical operators](search-query-odata-logical-operators.md).
79
69
80
70
> [!NOTE]
81
-
> Azure AI Search does not support using `search.ismatch` or `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 AI Search](search-query-troubleshoot-collection-filters.md). For more in-depth information on why this limitation exists, see [Understanding collection filters in Azure AI Search](search-query-understand-collection-filters.md).
71
+
> Azure AI Search doesn't support using `search.ismatch` or `search.ismatchscoring` inside lambda expressions. This means it isn't 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 information on this limitation as well as examples, see [Troubleshooting collection filters in Azure AI Search](search-query-troubleshoot-collection-filters.md). For more in-depth information on why this limitation exists, see [Understanding collection filters in Azure AI Search](search-query-understand-collection-filters.md).
82
72
83
73
84
74
### search.ismatchscoring
85
75
86
-
The `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.ismatch`:
76
+
The `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 contributes to the overall document score, whereas for `search.ismatch`, the document score doesn't change. The following overloads of this function are available with parameters identical to those of `search.ismatch`:
87
77
88
78
-`search.ismatchscoring(search)`
89
79
-`search.ismatchscoring(search, searchFields)`
@@ -99,10 +89,36 @@ Find documents with the word "waterfront". This filter query is identical to a [
99
89
search.ismatchscoring('waterfront')
100
90
```
101
91
102
-
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` function.
92
+
Here's the full query syntax for this request, which you can run in Search Explorer in the Azure portal. Output consists of matches on waterfront, water, and front.
93
+
94
+
```json
95
+
{
96
+
"search": "*",
97
+
"select": "HotelId, HotelName, Description",
98
+
"searchMode": "all",
99
+
"queryType": "simple",
100
+
"count": true,
101
+
"filter": "search.ismatchscoring('waterfront')"
102
+
}
103
+
```
104
+
105
+
Find documents with the word "pool" and rating greater or equal to 4, or documents with the word "motel" and equal to 3.2. Note, this request couldn't be expressed without the `search.ismatchscoring` function.
103
106
104
107
```odata-filter-expr
105
-
search.ismatchscoring('hostel') and Rating ge 4 or search.ismatchscoring('motel') and Rating eq 5
108
+
search.ismatchscoring('pool') and Rating ge 4 or search.ismatchscoring('motel') and Rating eq 3.2
109
+
```
110
+
111
+
Here's the full query syntax for this request for Search Explorer. Output consists of matches on hotels with pools having a rating greater than 4, *or* motels with a rating equal to 3.2.
"filter": "search.ismatchscoring('pool') and Rating ge 4 or search.ismatchscoring('motel') and Rating eq 3.2"
121
+
}
106
122
```
107
123
108
124
Find documents without the word "luxury".
@@ -111,26 +127,179 @@ Find documents without the word "luxury".
111
127
not search.ismatch('luxury')
112
128
```
113
129
114
-
Find documents with the phrase "ocean view" or rating equal to 5. The `search.ismatchscoring` query will be executed only against fields `HotelName` and `Rooms/Description`.
130
+
Find documents with the phrase "ocean" or rating equal to 3.2. The `search.ismatchscoring` query is executed only against fields `HotelName` and `Description`.
115
131
116
-
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.
132
+
Documents that matched only the second clause of the disjunction will be returned too -- hotels with `Rating` equal to `3.2`. To make it clear that those documents didn't match any of the scored parts of the expression, they're returned with score equal to zero.
117
133
118
-
```odata-filter-expr
119
-
search.ismatchscoring('"ocean view"', 'Rooms/Description,HotelName') or Rating eq 5
"filter": "search.ismatchscoring('ocean', 'Description,HotelName') or Rating eq 3.2"
142
+
}
143
+
```
144
+
145
+
Output consists of 4 matches: hotels that mention "ocean" in the Description or Hotel Name, or hotels with a rating of 3.2.
146
+
147
+
```json
148
+
{
149
+
"@odata.count": 4,
150
+
"value": [
151
+
{
152
+
"@search.score": 1.6076145,
153
+
"HotelId": "18",
154
+
"HotelName": "Ocean Water Resort & Spa",
155
+
"Description": "New Luxury Hotel for the vacation of a lifetime. Bay views from every room, location near the pier, rooftop pool, waterfront dining & more.",
156
+
"Rating": 4.2
157
+
},
158
+
{
159
+
"@search.score": 1.0594962,
160
+
"HotelId": "41",
161
+
"HotelName": "Windy Ocean Motel",
162
+
"Description": "Oceanfront hotel overlooking the beach features rooms with a private balcony and 2 indoor and outdoor pools. Inspired by the natural beauty of the island, each room includes an original painting of local scenes by the owner. Rooms include a mini fridge, Keurig coffee maker, and flatscreen TV. Various shops and art entertainment are on the boardwalk, just steps away.",
163
+
"Rating": 3.5
164
+
},
165
+
{
166
+
"@search.score": 0,
167
+
"HotelId": "40",
168
+
"HotelName": "Trails End Motel",
169
+
"Description": "Only 8 miles from Downtown. On-site bar/restaurant, Free hot breakfast buffet, Free wireless internet, All non-smoking hotel. Only 15 miles from airport.",
170
+
"Rating": 3.2
171
+
},
172
+
{
173
+
"@search.score": 0,
174
+
"HotelId": "26",
175
+
"HotelName": "Planetary Plaza & Suites",
176
+
"Description": "Extend Your Stay. Affordable home away from home, with amenities like free Wi-Fi, full kitchen, and convenient laundry service.",
177
+
"Rating": 3.2
178
+
}
179
+
]
180
+
}
120
181
```
121
182
122
-
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](query-lucene-syntax.md).
183
+
Find documents where the terms "hotel" and "airport" are within 5 words from each other in the description of the hotel, and where smoking isn't allowed in at least some of the rooms.
123
184
124
185
```odata-filter-expr
125
186
search.ismatch('"hotel airport"~5', 'Description', 'full', 'any') and Rooms/any(room: not room/SmokingAllowed)
126
187
```
127
188
189
+
Here's the full query syntax. To run in Search Explorer, escape the interior quotation marks with a backslash character.
"filter": "search.ismatch('\"hotel airport\"~5', 'Description', 'full', 'any') and Rooms/any(room: not room/SmokingAllowed)"
199
+
}
200
+
```
201
+
202
+
Output consists of a single document where the terms "hotel" and "airport" are within 5 words distance. Smoking is allowed for several rooms in most hotels, including the one in this search result.
203
+
204
+
```json
205
+
{
206
+
"@odata.count": 1,
207
+
"value": [
208
+
{
209
+
"@search.score": 1,
210
+
"HotelId": "40",
211
+
"HotelName": "Trails End Motel",
212
+
"Description": "Only 8 miles from Downtown. On-site bar/restaurant, Free hot breakfast buffet, Free wireless internet, All non-smoking hotel. Only 15 miles from airport.",
213
+
"Tags": [
214
+
"bar",
215
+
"free wifi",
216
+
"restaurant"
217
+
],
218
+
"Rating": 3.2
219
+
}
220
+
]
221
+
}
222
+
```
223
+
128
224
Find documents that have a word that starts with the letters "lux" in the Description field. This query uses [prefix search](query-simple-syntax.md#prefix-queries) in combination with `search.ismatch`.
"Description": "New Luxury Hotel for the vacation of a lifetime. Bay views from every room, location near the pier, rooftop pool, waterfront dining & more.",
254
+
"Tags": [
255
+
"view",
256
+
"pool",
257
+
"restaurant"
258
+
],
259
+
"Rating": 4.2
260
+
},
261
+
{
262
+
"@search.score": 1,
263
+
"HotelId": "13",
264
+
"HotelName": "Luxury Lion Resort",
265
+
"Description": "Unmatched Luxury. Visit our downtown hotel to indulge in luxury accommodations. Moments from the stadium and transportation hubs, we feature the best in convenience and comfort.",
266
+
"Tags": [
267
+
"bar",
268
+
"concierge",
269
+
"restaurant"
270
+
],
271
+
"Rating": 4.1
272
+
},
273
+
{
274
+
"@search.score": 1,
275
+
"HotelId": "16",
276
+
"HotelName": "Double Sanctuary Resort",
277
+
"Description": "5 star Luxury Hotel - Biggest Rooms in the city. #1 Hotel in the area listed by Traveler magazine. Free WiFi, Flexible check in/out, Fitness Center & espresso in room.",
278
+
"Tags": [
279
+
"view",
280
+
"pool",
281
+
"restaurant",
282
+
"bar",
283
+
"continental breakfast"
284
+
],
285
+
"Rating": 4.2
286
+
},
287
+
{
288
+
"@search.score": 1,
289
+
"HotelId": "14",
290
+
"HotelName": "Twin Vortex Hotel",
291
+
"Description": "New experience in the making. Be the first to experience the luxury of the Twin Vortex. Reserve one of our newly-renovated guest rooms today.",
0 commit comments