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/search-how-to-create-indexers.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -167,7 +167,7 @@ When you're ready to create an indexer on a remote search service, you need a se
167
167
168
168
+[**Import data** wizard](search-import-data-portal.md): The wizard is unique in that it creates all of the required elements. Other approaches require a predefined data source and index.
169
169
170
-
:::image type="content" source="media/search-how-to-create-indexers/portal-indexer-client.png" alt-text="Screenshot that shows the Import data wizrd." border="true":::
170
+
:::image type="content" source="media/search-how-to-create-indexers/portal-indexer-client.png" alt-text="Screenshot that shows the Import data wizard." border="true":::
171
171
172
172
+**Add indexer**: A visual editor for specifying an indexer definition.
Copy file name to clipboardExpand all lines: articles/search/search-query-create.md
+28-28Lines changed: 28 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
---
2
-
title: Full-text query how-to
2
+
title: Create a full text query
3
3
titleSuffix: Azure AI Search
4
4
description: Learn how to construct a query request for full text search in Azure AI Search.
5
5
@@ -10,16 +10,16 @@ ms.service: cognitive-search
10
10
ms.custom:
11
11
- ignite-2023
12
12
ms.topic: how-to
13
-
ms.date: 11/16/2023
13
+
ms.date: 10/10/2024
14
14
---
15
15
16
-
# Create a full-text query in Azure AI Search
16
+
# Create a fulltext query in Azure AI Search
17
17
18
-
If you're building a query for [full text search](search-lucene-query-architecture.md), this article provides steps for setting up the request. It also introduces a query structure, and explains how field attributes and linguistic analyzers can impact query outcomes.
18
+
If you're building a query for [full text search](search-lucene-query-architecture.md), this article provides steps for setting up the request. It also introduces a query structure, and explains how field attributes and linguistic analyzers can affect query outcomes.
19
19
20
20
## Prerequisites
21
21
22
-
+ A [search index](search-how-to-create-search-index.md) with string fields attributed as `searchable`.
22
+
+ A [search index](search-how-to-create-search-index.md) with string fields attributed as *searchable*.
23
23
24
24
+ Read permissions on the search index. For read access, include a [query API key](search-security-api-keys.md) on the request, or give the caller [Search Index Data Reader](search-security-rbac.md) permissions.
25
25
@@ -29,7 +29,7 @@ In Azure AI Search, a query is a read-only request against the docs collection o
29
29
30
30
A full text query is specified in a `search` parameter and consists of terms, quote-enclosed phrases, and operators. Other parameters add more definition to the request.
31
31
32
-
The following [Search POST REST API](/rest/api/searchservice/documents/search-post) call illustrates a query request using the aforementioned parameters.
32
+
The following [Search POST REST API](/rest/api/searchservice/documents/search-post) call illustrates a query request using the mentioned parameters.
33
33
34
34
```http
35
35
POST https://[service name].search.windows.net/indexes/hotels-sample-index/docs/search?api-version=2024-07-01
@@ -44,41 +44,41 @@ POST https://[service name].search.windows.net/indexes/hotels-sample-index/docs/
44
44
}
45
45
```
46
46
47
-
**Key points:**
47
+
### Key points
48
48
49
-
+**`search`** provides the match criteria, usually whole terms or phrases, with or without operators. Any field that is attributed as "searchable" in the index schema is a candidate for this parameter.
49
+
+**`search`** provides the match criteria, usually whole terms or phrases, with or without operators. Any field that is attributed as *searchable* in the index schema is a candidate for this parameter.
50
50
51
-
+**`queryType`** sets the parser: `simple`, `full`. The [default simple query parser](search-query-simple-examples.md) is optimal for full text search. The [full Lucene query parser](search-query-lucene-examples.md) is for advanced query constructs like regular expressions, proximity search, fuzzy and wildcard search. This parameter can also be set to `semantic` for [semantic ranking](semantic-search-overview.md) for advanced semantic modeling on the query response.
51
+
+**`queryType`** sets the parser: *simple*, *full*. The [default simple query parser](search-query-simple-examples.md) is optimal for full text search. The [full Lucene query parser](search-query-lucene-examples.md) is for advanced query constructs like regular expressions, proximity search, fuzzy and wildcard search. This parameter can also be set to *semantic* for [semantic ranking](semantic-search-overview.md) for advanced semantic modeling on the query response.
52
52
53
-
+**`searchMode`** specifies whether matches are based on "all" criteria (favors precision) or "any" criteria (favors recall) in the expression. The default is "any". If you anticipate heavy use of Boolean operators, which is more likely in indexes that contain large text blocks (a content field or long descriptions), be sure to test queries with the **`searchMode=Any|All`** parameter to evaluate the impact of that setting on boolean search.
53
+
+**`searchMode`** specifies whether matches are based on *all* criteria (favors precision) or *any* criteria (favors recall) in the expression. The default is *any*. If you anticipate heavy use of Boolean operators, which is more likely in indexes that contain large text blocks (a content field or long descriptions), be sure to test queries with the `searchMode=Any|All` parameter to evaluate the impact of that setting on Boolean search.
54
54
55
55
+**`searchFields`** constrains query execution to specific searchable fields. During development, it's helpful to use the same field list for select and search. Otherwise a match might be based on field values that you can't see in the results, creating uncertainty as to why the document was returned.
56
56
57
57
Parameters used to shape the response:
58
58
59
-
+**`select`** specifies which fields to return in the response. Only fields marked as "retrievable" in the index can be used in a select statement.
59
+
+**`select`** specifies which fields to return in the response. Only fields marked as *retrievable* in the index can be used in a select statement.
60
60
61
61
+**`top`** returns the specified number of best-matching documents. In this example, only 10 hits are returned. You can use top and skip (not shown) to page the results.
62
62
63
63
+**`count`** tells you how many documents in the entire index match overall, which can be more than what are returned.
64
64
65
-
+**`orderby`** is used if you want to sort results by a value, such as a rating or location. Otherwise, the default is to use the relevance score to rank results. A field must be attributed as "sortable" to be a candidate for this parameter.
65
+
+**`orderby`** is used if you want to sort results by a value, such as a rating or location. Otherwise, the default is to use the relevance score to rank results. A field must be attributed as *sortable* to be a candidate for this parameter.
66
66
67
67
## Choose a client
68
68
69
-
For early development and proof-of-concept testing, start with Azure portal or a [REST client](search-get-started-rest.md). Both approaches are interactive, useful for targeted testing, and help you assess the effects of different properties without having to write any code.
69
+
For early development and proof-of-concept testing, start with the Azure portal or a REST client. Both approaches are interactive, useful for targeted testing, and help you assess the effects of different properties without having to write any code.
70
70
71
-
To call search from within an app, use the **Azure.Document.Search** client libraries in the Azure SDKs for .NET, Java, JavaScript, and Python.
71
+
To call search from within an app, use the `Azure.Document.Search` client libraries in the Azure SDKs for .NET, Java, JavaScript, and Python.
72
72
73
73
### [**Azure portal**](#tab/portal-text-query)
74
74
75
75
In the portal, when you open an index, you can work with Search Explorer alongside the index JSON definition in side-by-side tabs for easy access to field attributes. Check the **Fields** table to see which ones are searchable, sortable, filterable, and facetable while testing queries.
76
76
77
77
1. Sign in to the [Azure portal](https://portal.azure.com) and [find your search service](https://portal.azure.com/#blade/HubsExtension/BrowseResourceBlade/resourceType/Microsoft.Search%2FsearchServices).
78
78
79
-
1.Open **Indexes** and select an index.
79
+
1.In your service, select **Indexes** and choose an index.
80
80
81
-
1. An index opens to the [**Search explorer**](search-explorer.md) tab so that you can query right away. Switch to **JSON view** to specify query syntax.
81
+
1. An index opens to the [**Search explorer**](search-explorer.md) tab so that you can query right away. Switch to **Edit JSON** to specify query syntax.
82
82
83
83
Here's a full text search query expression that works for the Hotels sample index:
84
84
@@ -100,7 +100,7 @@ In the portal, when you open an index, you can work with Search Explorer alongsi
100
100
101
101
### [**REST API**](#tab/rest-text-query)
102
102
103
-
Use a REST client to set up a request. [Quickstart: Text search using REST](search-get-started-rest.md) has instructions if you need help with getting started.
103
+
Use a REST client to set up a request. If you need help with getting started, see [Quickstart: Text search using REST](search-get-started-rest.md).
104
104
105
105
The following example calls the REST API for full text search:
106
106
@@ -118,7 +118,7 @@ POST https://[service name].search.windows.net/indexes/hotels-sample-index/docs/
118
118
119
119
### [**Azure SDKs**](#tab/sdk-text-query)
120
120
121
-
The following Azure SDKs provide a **SearchClient** that has methods for formulating query requests.
121
+
The following Azure SDKs provide a `SearchClient` that has methods for formulating query requests.
122
122
123
123
| Azure SDK | Client | Examples |
124
124
|-----------|--------|----------|
@@ -133,41 +133,41 @@ The following Azure SDKs provide a **SearchClient** that has methods for formula
133
133
134
134
If your query is full text search, a query parser is used to process any text that's passed as search terms and phrases. Azure AI Search offers two query parsers.
135
135
136
-
+ The simple parser understands the [simple query syntax](query-simple-syntax.md). This parser was selected as the default for its speed and effectiveness in free form text queries. The syntax supports common search operators (AND, OR, NOT) for term and phrase searches, and prefix (`*`) search (as in "sea*" for Seattle and Seaside). A general recommendation is to try the simple parser first, and then move on to full parser if application requirements call for more powerful queries.
136
+
+ The simple parser understands the [simple query syntax](query-simple-syntax.md). This parser was selected as the default for its speed and effectiveness in free form text queries. The syntax supports common search operators (AND, OR, NOT) for term and phrase searches, and prefix (`*`) search (as in `sea*` for Seattle and Seaside). A general recommendation is to try the simple parser first, and then move on to full parser if application requirements call for more powerful queries.
137
137
138
138
+ The [full Lucene query syntax](query-Lucene-syntax.md#bkmk_syntax), enabled when you add `queryType=full` to the request, is based on the [Apache Lucene Parser](https://lucene.apache.org/core/6_6_1/queryparser/org/apache/lucene/queryparser/classic/package-summary.html).
139
139
140
-
Full syntax and simple syntax overlap to the extent that both support the same prefix and boolean operations, but the full syntax provides more operators. In full, there are more operators for boolean expressions, and more operators for advanced queries such as fuzzy search, wildcard search, proximity search, and regular expressions.
140
+
Full syntax and simple syntax overlap to the extent that both support the same prefix and Boolean operations, but the full syntax provides more operators. In full, there are more operators for Boolean expressions, and more operators for advanced queries such as fuzzy search, wildcard search, proximity search, and regular expressions.
141
141
142
142
## Choose query methods
143
143
144
144
Search is fundamentally a user-driven exercise, where terms or phrases are collected from a search box, or from click events on a page. The following table summarizes the mechanisms by which you can collect user input, along with the expected search experience.
145
145
146
146
| Input | Experience |
147
147
|-------|---------|
148
-
|[Search method](/rest/api/searchservice/documents/search-post)| A user types the terms or phrases into a search box, with or without operators, and clicks Search to send the request. Search can be used with filters on the same request, but not with autocomplete or suggestions. |
149
-
|[Autocomplete method](/rest/api/searchservice/documents/autocomplete-post)| A user types a few characters, and queries are initiated after each new character is typed. The response is a completed string from the index. If the string provided is valid, the user clicks Search to send that query to the service. |
150
-
|[Suggestions method](/rest/api/searchservice/documents/suggest-post)| As with autocomplete, a user types a few characters and incremental queries are generated. The response is a dropdown list of matching documents, typically represented by a few unique or descriptive fields. If any of the selections are valid, the user clicks one and the matching document is returned. |
148
+
|[Search method](/rest/api/searchservice/documents/search-post)| A user types the terms or phrases into a search box, with or without operators, and selects **Search** to send the request. Search can be used with filters on the same request, but not with autocomplete or suggestions. |
149
+
|[Autocomplete method](/rest/api/searchservice/documents/autocomplete-post)| A user types a few characters, and queries are initiated after each new character is typed. The response is a completed string from the index. If the string provided is valid, the user selects **Search** to send that query to the service. |
150
+
|[Suggestions method](/rest/api/searchservice/documents/suggest-post)| As with autocomplete, a user types a few characters and incremental queries are generated. The response is a dropdown list of matching documents, typically represented by a few unique or descriptive fields. If any of the selections are valid, the user selects one and the matching document is returned. |
151
151
|[Faceted navigation](/rest/api/searchservice/documents/search-post#searchrequest)| A page shows clickable navigation links or breadcrumbs that narrow the scope of the search. A faceted navigation structure is composed dynamically based on an initial query. For example, `search=*` to populate a faceted navigation tree composed of every possible category. A faceted navigation structure is created from a query response, but it's also a mechanism for expressing the next query. n REST API reference, `facets` is documented as a query parameter of a Search Documents operation, but it can be used without the `search` parameter.|
152
152
|[Filter method](/rest/api/searchservice/documents/search-post#searchrequest)| Filters are used with facets to narrow results. You can also implement a filter behind the page, for example to initialize the page with language-specific fields. In REST API reference, `$filter` is documented as a query parameter of a Search Documents operation, but it can be used without the `search` parameter.|
153
153
154
154
## Effect of field attributes on queries
155
155
156
-
If you're familiar with [query types and composition](search-query-overview.md), you might remember that the parameters on a query request depend on field attributes in an index. For example, only fields marked as `searchable` and `retrievable` can be used in queries and search results. When setting the `search`, `filter`, and `orderby` parameters in your request, you should check attributes to avoid unexpected results.
156
+
If you're familiar with [query types and composition](search-query-overview.md), you might remember that the parameters on a query request depend on field attributes in an index. For example, only fields marked as *searchable* and *retrievable* can be used in queries and search results. When setting the `search`, `filter`, and `orderby` parameters in your request, you should check attributes to avoid unexpected results.
157
157
158
-
In the portal screenshot below of the [hotels sample index](search-get-started-portal.md), only the last two fields "LastRenovationDate" and "Rating" are `sortable`, a requirement for use in an `"$orderby"` only clause.
158
+
In the following screenshot of the [hotels sample index](search-get-started-portal.md), only the last two fields **LastRenovationDate** and **Rating** are *sortable*, a requirement for use in an `"$orderby"` only clause.
159
159
160
-

160
+
:::image type="content" source="media/search-query-overview/hotel-sample-index-definition.png" alt-text="Screenshot that shows the index definition for the hotel sample.":::
161
161
162
162
For field attribute definitions, see [Create Index (REST API)](/rest/api/searchservice/indexes/create).
163
163
164
164
## Effect of tokens on queries
165
165
166
166
During indexing, the search engine uses a text analyzer on strings to maximize the potential for finding a match at query time. At a minimum, strings are lower-cased, but depending on the analyzer, might also undergo lemmatization and stop word removal. Larger strings or compound words are typically broken up by whitespace, hyphens, or dashes, and indexed as separate tokens.
167
167
168
-
The point to take away here's that what you think your index contains, and what's actually in it, can be different. If queries don't return expected results, you can inspect the tokens created by the analyzer through the [Analyze Text (REST API)](/rest/api/searchservice/indexes/analyze). For more information about tokenization and the impact on queries, see [Partial term search and patterns with special characters](search-query-partial-matching.md).
168
+
The key point is that what you think your index contains, and what's actually in it, can be different. If queries don't return expected results, you can inspect the tokens created by the analyzer through the [Analyze Text (REST API)](/rest/api/searchservice/indexes/analyze). For more information about tokenization and the effect on queries, see [Partial term search and patterns with special characters](search-query-partial-matching.md).
169
169
170
-
## Next steps
170
+
## Related content
171
171
172
172
Now that you have a better understanding of how query requests work, try the following quickstarts for hands-on experience.
0 commit comments