Skip to content

Commit 91d0153

Browse files
committed
fixed indenting
1 parent 6daa934 commit 91d0153

File tree

1 file changed

+63
-63
lines changed

1 file changed

+63
-63
lines changed

articles/search/tutorial-create-custom-analyzer.md

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ms.date: 03/07/2024
1313

1414
# Tutorial: Create a custom analyzer for phone numbers
1515

16-
In search solutions, strings that have complex patterns or special characters can be a challenge to work with because the [default analyzer](search-analyzers.md) strips out or misinterprets meaningful parts of a pattern, resulting in a poor search experience when users can't find the information they want. Phone numbers are a good example of strings that are hard to analyze. They come in a variety of formats, and they include special characters that the default analyzer ignores.
16+
In search solutions, strings that have complex patterns or special characters can be a challenge to work with because the [default analyzer](search-analyzers.md) strips out or misinterprets meaningful parts of a pattern, resulting in a poor search experience when users can't find the information they expected. Phone numbers are a classic example of strings that are hard to analyze. They come in a variety of formats, and they include special characters that the default analyzer ignores.
1717

1818
With phone numbers as its subject, this tutorial takes a close look at the problems of patterned data, and shows you to solve that problem using a [custom analyzer](index-add-custom-analyzers.md). The approach outlined here can be used as-is for phone numbers, or adapted for fields having the same characteristics (patterned, with special characters), such as URLs, emails, postal codes, and dates.
1919

@@ -33,11 +33,11 @@ The following services and tools are required for this tutorial.
3333

3434
+ [Azure AI Search](search-what-is-azure-search.md). [Create](search-create-service-portal.md) or [find an existing Azure AI Search resource](https://portal.azure.com/#blade/HubsExtension/BrowseResourceBlade/resourceType/Microsoft.Search%2FsearchServices) under your current subscription. You can use a free service for this quickstart.
3535

36-
## Download files
36+
### Download files
3737

3838
Source code for this tutorial is in the [custom-analyzers](https://github.com/Azure-Samples/azure-search-postman-samples/tree/main/custom-analyzers) folder in the [Azure-Samples/azure-search-postman-samples](https://github.com/Azure-Samples/azure-search-postman-samples) GitHub repository.
3939

40-
## Copy a key and URL
40+
### Copy a key and URL
4141

4242
The REST calls in this tutorial require a search service endpoint and an admin API key. You can get these values from the Azure portal.
4343

@@ -150,9 +150,9 @@ A valid API key establishes trust, on a per request basis, between the applicati
150150
}
151151
```
152152
153-
1. Let's try a few queries that mimic what a user might type. A user could search for `(425) 555-0100` in any number of formats and still expect results to be returned. Start by searching `(425) 555-0100`:
153+
1. Let's try a few queries similar to what a user might type. A user could search for `(425) 555-0100` in any number of formats and still expect results to be returned. Start by searching `(425) 555-0100`:
154154
155-
```http
155+
```http
156156
### Search for a phone number
157157
GET {{baseUrl}}/indexes/phone-numbers-index/docs/search?api-version=2023-11-01&search=(425) 555-0100 HTTP/1.1
158158
Content-Type: application/json
@@ -212,7 +212,7 @@ A valid API key establishes trust, on a per request basis, between the applicati
212212
213213
If you find these results confusing, you're not alone. In the next section, let's dig into why we're getting these results.
214214
215-
## How analyzers work
215+
## Review how analyzers work
216216
217217
To understand these search results, we need to understand what the analyzer is doing. From there, we can test the default analyzer using the [Analyze API](/rest/api/searchservice/indexes/analyze), providing a foundation for designing an analyzer that better meets our needs.
218218
@@ -443,70 +443,70 @@ All of the tokens in the output column exist in the index. If our query includes
443443
444444
1. Recreate the index using the new analyzer. This index schema adds a custom analyzer definition, and a custom analyzer assignment on the phone number field.
445445
446-
```http
446+
```http
447447
### Create a new index
448448
POST {{baseUrl}}/indexes?api-version=2023-11-01 HTTP/1.1
449449
Content-Type: application/json
450450
api-key: {{apiKey}}
451-
452-
{
453-
"name": "phone-numbers-index-2",
454-
"fields": [
455-
{
456-
"name": "id",
457-
"type": "Edm.String",
458-
"key": true,
459-
"searchable": true,
460-
"filterable": false,
461-
"facetable": false,
462-
"sortable": true
463-
},
464-
{
465-
"name": "phone_number",
466-
"type": "Edm.String",
467-
"sortable": false,
468-
"searchable": true,
469-
"filterable": false,
470-
"facetable": false,
471-
"analyzer": "phone_analyzer"
472-
}
473-
],
474-
"analyzers": [
475-
{
476-
"@odata.type": "#Microsoft.Azure.Search.CustomAnalyzer",
477-
"name": "phone_analyzer",
478-
"tokenizer": "keyword_v2",
479-
"tokenFilters": [
480-
"custom_ngram_filter"
451+
452+
{
453+
"name": "phone-numbers-index-2",
454+
"fields": [
455+
{
456+
"name": "id",
457+
"type": "Edm.String",
458+
"key": true,
459+
"searchable": true,
460+
"filterable": false,
461+
"facetable": false,
462+
"sortable": true
463+
},
464+
{
465+
"name": "phone_number",
466+
"type": "Edm.String",
467+
"sortable": false,
468+
"searchable": true,
469+
"filterable": false,
470+
"facetable": false,
471+
"analyzer": "phone_analyzer"
472+
}
481473
],
482-
"charFilters": [
483-
"phone_char_mapping"
484-
]
485-
}
486-
],
487-
"charFilters": [
488-
{
489-
"@odata.type": "#Microsoft.Azure.Search.MappingCharFilter",
490-
"name": "phone_char_mapping",
491-
"mappings": [
492-
"-=>",
493-
"(=>",
494-
")=>",
495-
"+=>",
496-
".=>",
497-
"\\u0020=>"
474+
"analyzers": [
475+
{
476+
"@odata.type": "#Microsoft.Azure.Search.CustomAnalyzer",
477+
"name": "phone_analyzer",
478+
"tokenizer": "keyword_v2",
479+
"tokenFilters": [
480+
"custom_ngram_filter"
481+
],
482+
"charFilters": [
483+
"phone_char_mapping"
484+
]
485+
}
486+
],
487+
"charFilters": [
488+
{
489+
"@odata.type": "#Microsoft.Azure.Search.MappingCharFilter",
490+
"name": "phone_char_mapping",
491+
"mappings": [
492+
"-=>",
493+
"(=>",
494+
")=>",
495+
"+=>",
496+
".=>",
497+
"\\u0020=>"
498+
]
499+
}
500+
],
501+
"tokenFilters": [
502+
{
503+
"@odata.type": "#Microsoft.Azure.Search.NGramTokenFilterV2",
504+
"name": "custom_ngram_filter",
505+
"minGram": 3,
506+
"maxGram": 20
507+
}
498508
]
499509
}
500-
],
501-
"tokenFilters": [
502-
{
503-
"@odata.type": "#Microsoft.Azure.Search.NGramTokenFilterV2",
504-
"name": "custom_ngram_filter",
505-
"minGram": 3,
506-
"maxGram": 20
507-
}
508-
]
509-
}
510510
```
511511
512512
<!-- With the custom analyzer defined, recreate the index so that the custom analyzer will be available for testing in the next step. For simplicity, the Postman collection creates a new index named `tutorial-first-analyzer` with the analyzer we defined. -->

0 commit comments

Comments
 (0)