Skip to content

Commit e692ce1

Browse files
Merge pull request #205085 from HeidiSteen/heidist-fresh
[azure search] Freshness pass on OData expression articles
2 parents 7d20764 + 7664ed6 commit e692ce1

File tree

5 files changed

+43
-74
lines changed

5 files changed

+43
-74
lines changed

articles/search/query-odata-filter-orderby-syntax.md

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@ author: bevloh
77
ms.author: beloh
88
ms.service: cognitive-search
99
ms.topic: conceptual
10-
ms.date: 10/06/2021
10+
ms.date: 07/18/2022
1111

1212
---
1313

1414
# OData language overview for `$filter`, `$orderby`, and `$select` in Azure Cognitive Search
1515

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:
1717

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.
1920

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:
2322

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.
2526

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.
2828

2929
> [!NOTE]
3030
> 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:
5151
5252
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.
5353

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.
5555

5656
Examples of field paths are shown in the following table:
5757

5858
| Field path | Description |
5959
| --- | --- |
6060
| `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')` |
6666

6767
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.
6868

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:
7070

7171
```odata
7272
Rooms/any(room: room/Type eq 'deluxe')
7373
```
7474

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.
7676

7777
### Using field paths
7878

@@ -216,18 +216,12 @@ An interactive syntax diagram is also available:
216216
> [!NOTE]
217217
> See [OData expression syntax reference for Azure Cognitive Search](search-query-odata-syntax-reference.md) for the complete EBNF.
218218
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
220220

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).
226222

227-
## See also
223+
The **$filter**, **$orderby**, and **$select** parameters are explored in more detail in the following articles:
228224

229-
- [Faceted navigation in Azure Cognitive Search](search-faceted-navigation.md)
230-
- [Filters in Azure Cognitive Search](search-filters.md)
231-
- [Search Documents (Azure Cognitive Search REST API)](/rest/api/searchservice/Search-Documents)
232-
- [Lucene query syntax](query-lucene-syntax.md)
233-
- [Simple query syntax in Azure Cognitive Search](query-simple-syntax.md)
225+
+ [OData $filter syntax in Azure Cognitive Search](search-query-odata-filter.md)
226+
+ [OData $orderby syntax in Azure Cognitive Search](search-query-odata-orderby.md)
227+
+ [OData $select syntax in Azure Cognitive Search](search-query-odata-select.md)

articles/search/search-query-odata-filter.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,14 @@ author: bevloh
88
ms.author: beloh
99
ms.service: cognitive-search
1010
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
2312
---
2413

2514
# OData $filter syntax in Azure Cognitive Search
2615

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).
2819

2920
## Syntax
3021

articles/search/search-query-odata-orderby.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,14 @@ author: bevloh
88
ms.author: beloh
99
ms.service: cognitive-search
1010
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
2312
---
13+
2414
# OData $orderby syntax in Azure Cognitive Search
2515

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).
2719

2820
## Syntax
2921

articles/search/search-query-odata-select.md

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,14 @@ author: bevloh
88
ms.author: beloh
99
ms.service: cognitive-search
1010
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
2312
---
13+
2414
# OData $select syntax in Azure Cognitive Search
2515

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).
2719

2820
## Syntax
2921

@@ -52,11 +44,11 @@ The **$select** parameter comes in two forms:
5244

5345
When using the second form, you may only specify retrievable fields in the list.
5446

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.
5648

5749
## Examples
5850

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`:
6052

6153
```odata-filter-expr
6254
$select=HotelId, HotelName, Rating, Address/City
@@ -75,7 +67,7 @@ An example result might look like this:
7567
}
7668
```
7769

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:
7971

8072
```odata-filter-expr
8173
$select=HotelName, Address, Rooms/Type, Rooms/BaseRate

articles/search/search-query-odata-syntax-reference.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ author: bevloh
88
ms.author: beloh
99
ms.service: cognitive-search
1010
ms.topic: reference
11-
ms.date: 09/16/2021
11+
ms.date: 07/18/2022
1212

1313
---
1414
# OData expression syntax reference for Azure Cognitive Search
1515

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).
1717

1818
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.
1919

@@ -24,7 +24,7 @@ We can describe the subset of the OData language supported by Azure Cognitive Se
2424
- [`$filter`](search-query-odata-filter.md), defined by the `filter_expression` rule.
2525
- [`$orderby`](search-query-odata-orderby.md), defined by the `order_by_expression` rule.
2626
- [`$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.
2828

2929
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.
3030

0 commit comments

Comments
 (0)