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
Copy file name to clipboardExpand all lines: articles/search/query-odata-filter-orderby-syntax.md
+23-29Lines changed: 23 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,24 +7,24 @@ author: bevloh
7
7
ms.author: beloh
8
8
ms.service: cognitive-search
9
9
ms.topic: conceptual
10
-
ms.date: 10/06/2021
10
+
ms.date: 07/18/2022
11
11
12
12
---
13
13
14
14
# OData language overview for `$filter`, `$orderby`, and `$select` in Azure Cognitive Search
15
15
16
-
Azure Cognitive Search supports a subset of the OData expression syntax for **$filter**, **$orderby**, and **$select** expressions. Filter expressions are evaluated during query parsing, constraining search to specific fields or adding match criteria used during index scans. Order-by expressions are applied as a post-processing step over a result set to sort the documents that are returned. Select expressions determine which document fields are included in the result set. The syntax of these expressions is distinct from the [simple](query-simple-syntax.md) or [full](query-lucene-syntax.md) query syntax that is used in the **search** parameter, although there's some overlap in the syntax for referencing fields.
16
+
This article provides an overview of the OData expression language used in $filter, $order-by, and $select expressions in Azure Cognitive Search. The language is presented "bottom-up" starting with the most basic elements. The OData expressions that you can construct in a query request range from simple to highly complex, but they all share common elements. Shared elements include:
17
17
18
-
This article provides an overview of the OData expression language used in filters, order-by, and select expressions. The language is presented "bottom-up", starting with the most basic elements and building on them. The top-level syntax for each parameter is described in a separate article:
18
+
+**Field paths**, which refer to specific fields of your index.
19
+
+**Constants**, which are literal values of a certain data type.
19
20
20
-
-[$filter syntax](search-query-odata-filter.md)
21
-
-[$orderby syntax](search-query-odata-orderby.md)
22
-
-[$select syntax](search-query-odata-select.md)
21
+
Once you understand these common concepts, you can continue with the top-level syntax for each expression:
23
22
24
-
OData expressions range from simple to highly complex, but they all share common elements. The most basic parts of an OData expression in Azure Cognitive Search are:
23
+
+[**$filter**](search-query-odata-filter.md) expressions are evaluated during query parsing, constraining search to specific fields or adding match criteria used during index scans.
24
+
+[**$orderby**](search-query-odata-orderby.md) expressions are applied as a post-processing step over a result set to sort the documents that are returned.
25
+
+[**$select**](search-query-odata-select.md) expressions determine which document fields are included in the result set.
25
26
26
-
-**Field paths**, which refer to specific fields of your index.
27
-
-**Constants**, which are literal values of a certain data type.
27
+
The syntax of these expressions is distinct from the [simple](query-simple-syntax.md) or [full](query-lucene-syntax.md) query syntax used in the **search** parameter, although there's some overlap in the syntax for referencing fields.
28
28
29
29
> [!NOTE]
30
30
> Terminology in Azure Cognitive Search differs from the [OData standard](https://www.odata.org/documentation/) in a few ways. What we call a **field** in Azure Cognitive Search is called a **property** in OData, and similarly for **field path** versus **property path**. An **index** containing **documents** in Azure Cognitive Search is referred to more generally in OData as an **entity set** containing **entities**. The Azure Cognitive Search terminology is used throughout this reference.
@@ -51,28 +51,28 @@ An interactive syntax diagram is also available:
51
51
52
52
A field path is composed of one or more **identifiers** separated by slashes. Each identifier is a sequence of characters that must start with an ASCII letter or underscore, and contain only ASCII letters, digits, or underscores. The letters can be upper- or lower-case.
53
53
54
-
An identifier can refer either to the name of a field, or to a **range variable** in the context of a [collection expression](search-query-odata-collection-operators.md) (`any` or `all`) in a filter. A range variable is like a loop variable that represents the current element of the collection. For complex collections, that variable represents an object, which is why you can use field paths to refer to sub-fields of the variable. This is analogous to dot notation in many programming languages.
54
+
An identifier can refer either to the name of a field, or to a **range variable** in the context of a [collection expression](search-query-odata-collection-operators.md) (`any` or `all`) in a filter. A range variable is like a loop variable that represents the current element of the collection. For complex collections, that variable represents an object, which is why you can use field paths to refer to subfields of the variable. This is analogous to dot notation in many programming languages.
55
55
56
56
Examples of field paths are shown in the following table:
57
57
58
58
| Field path | Description |
59
59
| --- | --- |
60
60
|`HotelName`| Refers to a top-level field of the index |
61
-
|`Address/City`| Refers to the `City`sub-field of a complex field in the index; `Address` is of type `Edm.ComplexType` in this example |
62
-
|`Rooms/Type`| Refers to the `Type`sub-field of a complex collection field in the index; `Rooms` is of type `Collection(Edm.ComplexType)` in this example |
63
-
|`Stores/Address/Country`| Refers to the `Country`sub-field of the `Address`sub-field of a complex collection field in the index; `Stores` is of type `Collection(Edm.ComplexType)` and `Address` is of type `Edm.ComplexType` in this example |
64
-
|`room/Type`| Refers to the `Type`sub-field of the `room` range variable, for example in the filter expression `Rooms/any(room: room/Type eq 'deluxe')`|
65
-
|`store/Address/Country`| Refers to the `Country`sub-field of the `Address`sub-field of the `store` range variable, for example in the filter expression `Stores/any(store: store/Address/Country eq 'Canada')`|
61
+
|`Address/City`| Refers to the `City`subfield of a complex field in the index; `Address` is of type `Edm.ComplexType` in this example |
62
+
|`Rooms/Type`| Refers to the `Type`subfield of a complex collection field in the index; `Rooms` is of type `Collection(Edm.ComplexType)` in this example |
63
+
|`Stores/Address/Country`| Refers to the `Country`subfield of the `Address`subfield of a complex collection field in the index; `Stores` is of type `Collection(Edm.ComplexType)` and `Address` is of type `Edm.ComplexType` in this example |
64
+
|`room/Type`| Refers to the `Type`subfield of the `room` range variable, for example in the filter expression `Rooms/any(room: room/Type eq 'deluxe')`|
65
+
|`store/Address/Country`| Refers to the `Country`subfield of the `Address`subfield of the `store` range variable, for example in the filter expression `Stores/any(store: store/Address/Country eq 'Canada')`|
66
66
67
67
The meaning of a field path differs depending on the context. In filters, a field path refers to the value of a *single instance* of a field in the current document. In other contexts, such as **$orderby**, **$select**, or in [fielded search in the full Lucene syntax](query-lucene-syntax.md#bkmk_fields), a field path refers to the field itself. This difference has some consequences for how you use field paths in filters.
68
68
69
-
Consider the field path `Address/City`. In a filter, this refers to a single city for the current document, like "San Francisco". In contrast, `Rooms/Type` refers to the `Type`sub-field for many rooms (like "standard" for the first room, "deluxe" for the second room, and so on). Since `Rooms/Type` doesn't refer to a *single instance* of the sub-field`Type`, it can't be used directly in a filter. Instead, to filter on room type, you would use a [lambda expression](search-query-odata-collection-operators.md) with a range variable, like this:
69
+
Consider the field path `Address/City`. In a filter, this refers to a single city for the current document, like "San Francisco". In contrast, `Rooms/Type` refers to the `Type`subfield for many rooms (like "standard" for the first room, "deluxe" for the second room, and so on). Since `Rooms/Type` doesn't refer to a *single instance* of the subfield`Type`, it can't be used directly in a filter. Instead, to filter on room type, you would use a [lambda expression](search-query-odata-collection-operators.md) with a range variable, like this:
70
70
71
71
```odata
72
72
Rooms/any(room: room/Type eq 'deluxe')
73
73
```
74
74
75
-
In this example, the range variable `room` appears in the `room/Type` field path. That way, `room/Type` refers to the type of the current room in the current document. This is a single instance of the `Type`sub-field, so it can be used directly in the filter.
75
+
In this example, the range variable `room` appears in the `room/Type` field path. That way, `room/Type` refers to the type of the current room in the current document. This is a single instance of the `Type`subfield, so it can be used directly in the filter.
76
76
77
77
### Using field paths
78
78
@@ -216,18 +216,12 @@ An interactive syntax diagram is also available:
216
216
> [!NOTE]
217
217
> See [OData expression syntax reference for Azure Cognitive Search](search-query-odata-syntax-reference.md) for the complete EBNF.
218
218
219
-
The **$orderby** and **$select** parameters are both comma-separated lists of simpler expressions. The **$filter** parameter is a Boolean expression that is composed of simpler sub-expressions. These sub-expressions are combined using logical operators such as [`and`, `or`, and `not`](search-query-odata-logical-operators.md), comparison operators such as [`eq`, `lt`, `gt`, and so on](search-query-odata-comparison-operators.md), and collection operators such as [`any` and `all`](search-query-odata-collection-operators.md).
219
+
## Next steps
220
220
221
-
The **$filter**, **$orderby**, and **$select** parameters are explored in more detail in the following articles:
222
-
223
-
-[OData $filter syntax in Azure Cognitive Search](search-query-odata-filter.md)
224
-
-[OData $orderby syntax in Azure Cognitive Search](search-query-odata-orderby.md)
225
-
-[OData $select syntax in Azure Cognitive Search](search-query-odata-select.md)
221
+
The **$orderby** and **$select** parameters are both comma-separated lists of simpler expressions. The **$filter** parameter is a Boolean expression that is composed of simpler subexpressions. These subexpressions are combined using logical operators such as [`and`, `or`, and `not`](search-query-odata-logical-operators.md), comparison operators such as [`eq`, `lt`, `gt`, and so on](search-query-odata-comparison-operators.md), and collection operators such as [`any` and `all`](search-query-odata-collection-operators.md).
226
222
227
-
## See also
223
+
The **$filter**, **$orderby**, and **$select** parameters are explored in more detail in the following articles:
228
224
229
-
-[Faceted navigation in Azure Cognitive Search](search-faceted-navigation.md)
230
-
-[Filters in Azure Cognitive Search](search-filters.md)
Copy file name to clipboardExpand all lines: articles/search/search-query-odata-filter.md
+4-13Lines changed: 4 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,23 +8,14 @@ author: bevloh
8
8
ms.author: beloh
9
9
ms.service: cognitive-search
10
10
ms.topic: reference
11
-
ms.date: 09/16/2021
12
-
translation.priority.mt:
13
-
- "de-de"
14
-
- "es-es"
15
-
- "fr-fr"
16
-
- "it-it"
17
-
- "ja-jp"
18
-
- "ko-kr"
19
-
- "pt-br"
20
-
- "ru-ru"
21
-
- "zh-cn"
22
-
- "zh-tw"
11
+
ms.date: 07/18/2022
23
12
---
24
13
25
14
# OData $filter syntax in Azure Cognitive Search
26
15
27
-
Azure Cognitive Search uses [OData filter expressions](query-odata-filter-orderby-syntax.md) to apply additional criteria to a search query besides full-text search terms. This article describes the syntax of filters in detail. For more general information about what filters are and how to use them to realize specific query scenarios, see [Filters in Azure Cognitive Search](search-filters.md).
16
+
In Azure Cognitive Search, the **$filter** parameter specifies inclusion or exclusion criteria for returning matches in search results. This article describes the OData syntax of **$filter** and provides examples.
17
+
18
+
Field path construction and constants are described in the [OData language overview in Azure Cognitive Search](query-odata-filter-orderby-syntax.md). For more information about filter scenarios, see [Filters in Azure Cognitive Search](search-filters.md).
Copy file name to clipboardExpand all lines: articles/search/search-query-odata-orderby.md
+5-13Lines changed: 5 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,22 +8,14 @@ author: bevloh
8
8
ms.author: beloh
9
9
ms.service: cognitive-search
10
10
ms.topic: reference
11
-
ms.date: 09/16/2021
12
-
translation.priority.mt:
13
-
- "de-de"
14
-
- "es-es"
15
-
- "fr-fr"
16
-
- "it-it"
17
-
- "ja-jp"
18
-
- "ko-kr"
19
-
- "pt-br"
20
-
- "ru-ru"
21
-
- "zh-cn"
22
-
- "zh-tw"
11
+
ms.date: 07/18/2022
23
12
---
13
+
24
14
# OData $orderby syntax in Azure Cognitive Search
25
15
26
-
You can use the [OData **$orderby** parameter](query-odata-filter-orderby-syntax.md) to apply a custom sort order for search results in Azure Cognitive Search. This article describes the syntax of **$orderby** in detail. For more general information about how to use **$orderby** when presenting search results, see [How to work with search results in Azure Cognitive Search](search-pagination-page-layout.md).
16
+
In Azure Cognitive Search, the **$orderby** parameter specifies custom sort order for search results. This article describes the OData syntax of **$orderby** and provides examples.
17
+
18
+
Field path construction and constants are described in the [OData language overview in Azure Cognitive Search](query-odata-filter-orderby-syntax.md). For more information about sorting and search results composition, see [How to work with search results in Azure Cognitive Search](search-pagination-page-layout.md).
Copy file name to clipboardExpand all lines: articles/search/search-query-odata-select.md
+8-16Lines changed: 8 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,22 +8,14 @@ author: bevloh
8
8
ms.author: beloh
9
9
ms.service: cognitive-search
10
10
ms.topic: reference
11
-
ms.date: 09/16/2021
12
-
translation.priority.mt:
13
-
- "de-de"
14
-
- "es-es"
15
-
- "fr-fr"
16
-
- "it-it"
17
-
- "ja-jp"
18
-
- "ko-kr"
19
-
- "pt-br"
20
-
- "ru-ru"
21
-
- "zh-cn"
22
-
- "zh-tw"
11
+
ms.date: 07/18/2022
23
12
---
13
+
24
14
# OData $select syntax in Azure Cognitive Search
25
15
26
-
You can use the [OData **$select** parameter](query-odata-filter-orderby-syntax.md) to choose which fields to include in search results from Azure Cognitive Search. This article describes the syntax of **$select** in detail. For more general information about how to use **$select** when presenting search results, see [How to work with search results in Azure Cognitive Search](search-pagination-page-layout.md).
16
+
In Azure Cognitive Search, the **$select** parameter specifies which fields to include in search results. This article describes the OData syntax of **$select** and provides examples.
17
+
18
+
Field path construction and constants are described in the [OData language overview in Azure Cognitive Search](query-odata-filter-orderby-syntax.md). For more information about search result composition, see [How to work with search results in Azure Cognitive Search](search-pagination-page-layout.md).
27
19
28
20
## Syntax
29
21
@@ -52,11 +44,11 @@ The **$select** parameter comes in two forms:
52
44
53
45
When using the second form, you may only specify retrievable fields in the list.
54
46
55
-
If you list a complex field without specifying its sub-fields explicitly, all retrievable sub-fields will be included in the query result set. For example, assume your index has an `Address` field with `Street`, `City`, and `Country`sub-fields that are all retrievable. If you specify `Address` in **$select**, the query results will include all three sub-fields.
47
+
If you list a complex field without specifying its subfields explicitly, all retrievable subfields will be included in the query result set. For example, assume your index has an `Address` field with `Street`, `City`, and `Country`subfields that are all retrievable. If you specify `Address` in **$select**, the query results will include all three subfields.
56
48
57
49
## Examples
58
50
59
-
Include the `HotelId`, `HotelName`, and `Rating` top-level fields in the results, as well as the `City`sub-field of `Address`:
51
+
Include the `HotelId`, `HotelName`, and `Rating` top-level fields in the results, and include the `City`subfield of `Address`:
60
52
61
53
```odata-filter-expr
62
54
$select=HotelId, HotelName, Rating, Address/City
@@ -75,7 +67,7 @@ An example result might look like this:
75
67
}
76
68
```
77
69
78
-
Include the `HotelName` top-level field in the results, as well as all sub-fields of `Address`, and the `Type` and `BaseRate`sub-fields of each object in the `Rooms` collection:
70
+
Include the `HotelName` top-level field in the results. Include all subfields of `Address`. Include the `Type` and `BaseRate`subfields of each object in the `Rooms` collection:
Copy file name to clipboardExpand all lines: articles/search/search-query-odata-syntax-reference.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,12 +8,12 @@ author: bevloh
8
8
ms.author: beloh
9
9
ms.service: cognitive-search
10
10
ms.topic: reference
11
-
ms.date: 09/16/2021
11
+
ms.date: 07/18/2022
12
12
13
13
---
14
14
# OData expression syntax reference for Azure Cognitive Search
15
15
16
-
Azure Cognitive Search uses [OData expressions](https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html) as parameters throughout the API. Most commonly, OData expressions are used for the `$orderby` and `$filter` parameters. These expressions can be complex, containing multiple clauses, functions, and operators. However, even simple OData expressions like property paths are used in many parts of the Azure Cognitive Search REST API. For example, path expressions are used to refer to sub-fields of complex fields everywhere in the API, such as when listing sub-fields in a [suggester](index-add-suggesters.md), a [scoring function](index-add-scoring-profiles.md), the `$select` parameter, or even [fielded search in Lucene queries](query-lucene-syntax.md).
16
+
Azure Cognitive Search uses [OData expressions](https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html) as parameters throughout the API. Most commonly, OData expressions are used for the `$orderby` and `$filter` parameters. These expressions can be complex, containing multiple clauses, functions, and operators. However, even simple OData expressions like property paths are used in many parts of the Azure Cognitive Search REST API. For example, path expressions are used to refer to subfields of complex fields everywhere in the API, such as when listing subfields in a [suggester](index-add-suggesters.md), a [scoring function](index-add-scoring-profiles.md), the `$select` parameter, or even [fielded search in Lucene queries](query-lucene-syntax.md).
17
17
18
18
This article describes all these forms of OData expressions using a formal grammar. There is also an [interactive diagram](#syntax-diagram) to help visually explore the grammar.
19
19
@@ -24,7 +24,7 @@ We can describe the subset of the OData language supported by Azure Cognitive Se
24
24
-[`$filter`](search-query-odata-filter.md), defined by the `filter_expression` rule.
25
25
-[`$orderby`](search-query-odata-orderby.md), defined by the `order_by_expression` rule.
26
26
-[`$select`](search-query-odata-select.md), defined by the `select_expression` rule.
27
-
- Field paths, defined by the `field_path` rule. Field paths are used throughout the API. They can refer to either top-level fields of an index, or sub-fields with one or more [complex field](search-howto-complex-data-types.md) ancestors.
27
+
- Field paths, defined by the `field_path` rule. Field paths are used throughout the API. They can refer to either top-level fields of an index, or subfields with one or more [complex field](search-howto-complex-data-types.md) ancestors.
28
28
29
29
After the EBNF is a browsable [syntax diagram](https://en.wikipedia.org/wiki/Syntax_diagram) that allows you to interactively explore the grammar and the relationships between its rules.
0 commit comments