快速入门:使用 JavaScript SDK 创建 Azure 认知搜索索引Quickstart: Create an Azure Cognitive Search index using the JavaScript SDK

使用适用于 Azure 认知搜索 的 Javascript/Typscript SDK 在 JavaScript 中创建一个 Node.js 应用程序用于创建、加载和查询搜索索引。Use the Javascript/Typscript SDK for Azure Cognitive Search to create a Node.js application in JavaScript that creates, loads, and queries a search index.

本文演示如何逐步创建应用程序。This article demonstrates how to create the application step by step. 或者,可以下载源代码和数据,并从命令行运行应用程序。Alternatively, you can download the source code and data and run the application from the command line.

先决条件Prerequisites

开始之前,需具备以下工具和服务:Before you begin, have the following tools and services:

设置项目Set up your project

首先获取搜索服务的终结点和密钥。Start by getting the endpoint and key for your search service. 然后使用 NPM 创建一个新项目,如下所述。Then create a new project with NPM as outlined below.

复制密钥和终结点Copy a key and endpoint

对服务的调用要求每个请求都有一个 URL 终结点和一个访问密钥。Calls to the service require a URL endpoint and an access key on every request. 第一步,找到要添加到项目中的 API 密钥和 URL。As a first step, find the API key and URL to add to your project. 在稍后的步骤中创建客户端时,将指定这两个值。You will specify both values when creating the client in a later step.

  1. 登录到 Azure 门户,在搜索服务的“概述”页中获取 URL。Sign in to the Azure portal, and in your search service Overview page, get the URL. 示例终结点可能类似于 https://mydemo.search.azure.cnAn example endpoint might look like https://mydemo.search.azure.cn.

  2. 在“设置” > “密钥”中,获取管理员密钥以获得针对服务的完全权限,需要该密钥才可创建或删除对象 。In Settings > Keys, get an admin key for full rights on the service, required if you are creating or deleting objects. 有两个可互换的主要密钥和辅助密钥。There are two interchangeable primary and secondary keys. 可以使用其中任意一个。You can use either one.

    获取 HTTP 终结点和访问密钥Get an HTTP endpoint and access key

所有请求对发送到服务的每个请求都需要 API 密钥。All requests require an api-key on every request sent to your service. 具有有效的密钥可以在发送请求的应用程序与处理请求的服务之间建立信任关系,这种信任关系以每个请求为基础。Having a valid key establishes trust, on a per request basis, between the application sending the request and the service that handles it.

创建新的 NPM 项目Create a new NPM project

首先打开 VS Code 及其集成终端,或者打开其他终端,例如 Node.js 命令提示符。Begin by opening VS Code and its integrated terminal or another terminal such as the Node.js command prompt.

  1. 创建一个开发目录并将其命名为 quickstartCreate a development directory, giving it the name quickstart :

    mkdir quickstart
    cd quickstart
    
  2. 使用 NPM 初始化一个空项目,方法是运行Initialize an empty project with NPM by running

    npm init
    

    接受默认值,但“许可证”除外,其值应设置为“MIT”。Accept the default values, except for the License, which you should set to "MIT".

  3. 安装 @azure/search-documents,这是适用于 Azure 认知搜索的 Javascript/Typscript SDKInstall @azure/search-documents, the Javascript/Typscript SDK for Azure Cognitive Search.

    npm install @azure/search-documents
    
  4. 安装 dotenv,它用于导入环境变量,例如我们的服务名称和 API 密钥。Install dotenv, which is used to import the environment variables such as our service name and api key.

    npm install dotenv
    
  5. 检查你的 package.json 文件是否与以下 json 类似,确认已配置项目及其依赖项:Confirm that you've configured the projects and its dependencies by checking that your package.json file looks similar to the following json:

    {
      "name": "quickstart",
      "version": "1.0.0",
      "description": "Azure Cognitive Search Quickstart",
      "main": "index.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "keywords": [
        "Azure",
        "Search"
      ],
      "author": "Your Name",
      "license": "MIT",
      "dependencies": {
        "@azure/search-documents": "^11.0.3",
        "dotenv": "^8.2.0"
      }
    }
    
  6. 创建一个 .env 文件用来保存搜索服务参数:Create a file .env to hold your search service parameters:

    SEARCH_API_KEY=<search-admin-key>
    SEARCH_API_ENDPOINT=https://<search-service-name>.search.azure.cn
    

请将 <search-service-name> 值替换为搜索服务的名称。Replace the <search-service-name> value with the name of your search service. <search-admin-key> 替换为前面记下的密钥值。Replace <search-admin-key> with the key value you recorded earlier.

创建 index.js 文件Create index.js file

接下来,创建一个index.js 文件,它是托管代码的主要文件。Next we create an index.js file, which is the main file that will host our code.

在此文件的顶部导入 @azure/search-documents 库:At the top of this file, we import the @azure/search-documents library:

const { SearchIndexClient, SearchClient, AzureKeyCredential, odata } = require("@azure/search-documents");

接下来,需要 dotenv 包来从 .env 文件中读取参数,如下所示:Next, we need to require the dotenv package to read in the parameters from the .env file as follows:

// Load the .env file if it exists
require("dotenv").config();

// Getting endpoint and apiKey from .env file
const endpoint = process.env.SEARCH_API_ENDPOINT || "";
const apiKey = process.env.SEARCH_API_KEY || "";

在导入和环境变量设置完成后,就可定义 main 函数。With our imports and environment variables in place, we're ready to define the main function.

SDK 中的大部分功能都是异步的,因此我们将 main 函数设置为 asyncMost of the functionality in the SDK is asynchronous so we make our main function async. 我们还在 main 函数下面包含一个 main().catch() 来捕获和记录遇到的所有错误:We also include a main().catch() below the main function to catch and log any errors encountered:

async function main() {
    console.log(`Running Azure Cognitive Search Javascript quickstart...`);
    if (!endpoint || !apiKey) {
        console.log("Make sure to set valid values for endpoint and apiKey with proper authorization.");
        return;
    }

    // remaining quickstart code will go here
}

main().catch((err) => {
    console.error("The sample encountered an error:", err);
});

完成后,即可创建索引。With that in place, we're ready to create an index.

1 - 创建索引1 - Create index

创建文件 hotels_quickstart_index.jsonCreate a file hotels_quickstart_index.json. 此文件定义 Azure 认知搜索如何处理要在下一步骤中加载的文档。This file defines how Azure Cognitive Search works with the documents you'll be loading in the next step. 每个字段由 name 标识,采用指定的 typeEach field will be identified by a name and have a specified type. 每个字段还包含一系列索引属性,这些属性指定 Azure 认知搜索是否可以根据字段进行搜索、筛选、排序和分面。Each field also has a series of index attributes that specify whether Azure Cognitive Search can search, filter, sort, and facet upon the field. 大多数字段采用简单数据类型,但有些字段(例如 AddressType)采用复杂类型,可让你在索引中创建丰富的数据结构。Most of the fields are simple data types, but some, like AddressType are complex types that allow you to create rich data structures in your index. 可以详细了解支持的数据类型索引属性You can read more about supported data types and index attributes.

将以下内容添加到 hotels_quickstart_index.json下载文件Add the following to hotels_quickstart_index.json or download the file.

{
    "name": "hotels-quickstart",
    "fields": [
        {
            "name": "HotelId",
            "type": "Edm.String",
            "key": true,
            "filterable": true
        },
        {
            "name": "HotelName",
            "type": "Edm.String",
            "searchable": true,
            "filterable": false,
            "sortable": true,
            "facetable": false
        },
        {
            "name": "Description",
            "type": "Edm.String",
            "searchable": true,
            "filterable": false,
            "sortable": false,
            "facetable": false,
            "analyzer": "en.lucene"
        },
        {
            "name": "Description_fr",
            "type": "Edm.String",
            "searchable": true,
            "filterable": false,
            "sortable": false,
            "facetable": false,
            "analyzer": "fr.lucene"
        },
        {
            "name": "Category",
            "type": "Edm.String",
            "searchable": true,
            "filterable": true,
            "sortable": true,
            "facetable": true
        },
        {
            "name": "Tags",
            "type": "Collection(Edm.String)",
            "searchable": true,
            "filterable": true,
            "sortable": false,
            "facetable": true
        },
        {
            "name": "ParkingIncluded",
            "type": "Edm.Boolean",
            "filterable": true,
            "sortable": true,
            "facetable": true
        },
        {
            "name": "LastRenovationDate",
            "type": "Edm.DateTimeOffset",
            "filterable": true,
            "sortable": true,
            "facetable": true
        },
        {
            "name": "Rating",
            "type": "Edm.Double",
            "filterable": true,
            "sortable": true,
            "facetable": true
        },
        {
            "name": "Address",
            "type": "Edm.ComplexType",
            "fields": [
                {
                    "name": "StreetAddress",
                    "type": "Edm.String",
                    "filterable": false,
                    "sortable": false,
                    "facetable": false,
                    "searchable": true
                },
                {
                    "name": "City",
                    "type": "Edm.String",
                    "searchable": true,
                    "filterable": true,
                    "sortable": true,
                    "facetable": true
                },
                {
                    "name": "StateProvince",
                    "type": "Edm.String",
                    "searchable": true,
                    "filterable": true,
                    "sortable": true,
                    "facetable": true
                },
                {
                    "name": "PostalCode",
                    "type": "Edm.String",
                    "searchable": true,
                    "filterable": true,
                    "sortable": true,
                    "facetable": true
                },
                {
                    "name": "Country",
                    "type": "Edm.String",
                    "searchable": true,
                    "filterable": true,
                    "sortable": true,
                    "facetable": true
                }
            ]
        }
    ],
    "suggesters": [
        {
            "name": "sg",
            "searchMode": "analyzingInfixMatching",
            "sourceFields": [
                "HotelName"
            ]
        }
    ]
}

建立索引定义后,我们需要在 index.js 顶部导入 hotels_quickstart_index.json,使 main 函数能够访问索引定义 。With our index definition in place, we want to import hotels_quickstart_index.json at the top of index.js so the main function can access the index definition.

const indexDefinition = require('./hotels_quickstart_index.json');

然后在 main 函数中,我们创建一个 SearchIndexClient 用来创建和管理 Azure 认知搜索索引。Within the main function, we then create a SearchIndexClient, which is used to create and manage indexes for Azure Cognitive Search.

const indexClient = new SearchIndexClient(endpoint, new AzureKeyCredential(apiKey));

接下来,我们要删除该索引(如果它已存在)。Next, we want to delete the index if it already exists. 这是测试/演示代码的常见做法。This is a common practice for test/demo code.

为此,我们要定义一个简单函数,它会尝试删除索引。We do this by defining a simple function that tries to delete the index.

async function deleteIndexIfExists(indexClient, indexName) {
    try {
        await indexClient.deleteIndex(indexName);
        console.log('Deleting index...');
    } catch {
        console.log('Index does not exist yet.');
    }
}

为了运行该函数,我们将从索引定义中提取索引名称,并将 indexName 连同 indexClient 传递给 deleteIndexIfExists() 函数。To run the function, we extract the index name from the index definition and pass the indexName along with the indexClient to the deleteIndexIfExists() function.

const indexName = indexDefinition["name"];

console.log('Checking if index exists...');
await deleteIndexIfExists(indexClient, indexName);

之后,我们就可用 createIndex() 方法创建索引了。After that, we're ready to create the index with the createIndex() method.

console.log('Creating index...');
let index = await indexClient.createIndex(indexDefinition);

console.log(`Index named ${index.name} has been created.`);

运行示例Run the sample

此时就可运行示例了。At this point, you're ready to run the sample. 使用终端窗口运行以下命令:Use a terminal window to run the following command:

node index.js

如果已下载源代码,但尚未安装所需的包,请先运行 npm installIf you downloaded the source code and haven't installed the required packages yet, run npm install first.

你应会看到一系列消息,其中描述了程序正在执行的操作。You should see a series of messages describing the actions being taken by the program.

在 Azure 门户中打开搜索服务的“概述”。Open the Overview of your search service in the Azure portal. 选择“索引”选项卡。会看到下面这样的内容:Select the Indexes tab. You should see something like the following:

Azure 门户、搜索服务概述、“索引”选项卡的屏幕截图

在下一步骤中,你要向索引添加数据。In the next step, you'll add data to index.

2 - 加载文档2 - Load documents

在 Azure 认知搜索中,文档这一数据结构既是索引输入,也是查询输出。In Azure Cognitive Search, documents are data structures that are both inputs to indexing and outputs from queries. 可将此类数据推送到索引,或者使用索引器You can push such data to the index or use an indexer. 在本例中,我们将以编程方式将文档推送到索引。In this case, we'll programatically push the documents to the index.

文档输入可以是数据库中的行、Blob 存储中的 Blob,或磁盘上的 JSON 文档(在本示例中为 JSON 文档)。Document inputs might be rows in a database, blobs in Blob storage, or, as in this sample, JSON documents on disk. 可以下载 hotels.json,或创建包含以下内容的 hotels.json 文件:You can either download hotels.json or create your own hotels.json file with the following content:

{
    "value": [
        {
            "HotelId": "1",
            "HotelName": "Secret Point Motel",
            "Description": "The hotel is ideally located on the main commercial artery of the city in the heart of New York. A few minutes away is Time's Square and the historic centre of the city, as well as other places of interest that make New York one of America's most attractive and cosmopolitan cities.",
            "Description_fr": "L'hôtel est idéalement situé sur la principale artère commerciale de la ville en plein cœur de New York. A quelques minutes se trouve la place du temps et le centre historique de la ville, ainsi que d'autres lieux d'intérêt qui font de New York l'une des villes les plus attractives et cosmopolites de l'Amérique.",
            "Category": "Boutique",
            "Tags": ["pool", "air conditioning", "concierge"],
            "ParkingIncluded": false,
            "LastRenovationDate": "1970-01-18T00:00:00Z",
            "Rating": 3.6,
            "Address": {
                "StreetAddress": "677 5th Ave",
                "City": "New York",
                "StateProvince": "NY",
                "PostalCode": "10022"
            }
        },
        {
            "HotelId": "2",
            "HotelName": "Twin Dome Motel",
            "Description": "The hotel is situated in a  nineteenth century plaza, which has been expanded and renovated to the highest architectural standards to create a modern, functional and first-class hotel in which art and unique historical elements coexist with the most modern comforts.",
            "Description_fr": "L'hôtel est situé dans une place du XIXe siècle, qui a été agrandie et rénovée aux plus hautes normes architecturales pour créer un hôtel moderne, fonctionnel et de première classe dans lequel l'art et les éléments historiques uniques coexistent avec le confort le plus moderne.",
            "Category": "Boutique",
            "Tags": ["pool", "free wifi", "concierge"],
            "ParkingIncluded": "false",
            "LastRenovationDate": "1979-02-18T00:00:00Z",
            "Rating": 3.6,
            "Address": {
                "StreetAddress": "140 University Town Center Dr",
                "City": "Sarasota",
                "StateProvince": "FL",
                "PostalCode": "34243"
            }
        },
        {
            "HotelId": "3",
            "HotelName": "Triple Landscape Hotel",
            "Description": "The Hotel stands out for its gastronomic excellence under the management of William Dough, who advises on and oversees all of the Hotel’s restaurant services.",
            "Description_fr": "L'hôtel est situé dans une place du XIXe siècle, qui a été agrandie et rénovée aux plus hautes normes architecturales pour créer un hôtel moderne, fonctionnel et de première classe dans lequel l'art et les éléments historiques uniques coexistent avec le confort le plus moderne.",
            "Category": "Resort and Spa",
            "Tags": ["air conditioning", "bar", "continental breakfast"],
            "ParkingIncluded": "true",
            "LastRenovationDate": "2015-09-20T00:00:00Z",
            "Rating": 4.8,
            "Address": {
                "StreetAddress": "3393 Peachtree Rd",
                "City": "Atlanta",
                "StateProvince": "GA",
                "PostalCode": "30326"
            }
        },
        {
            "HotelId": "4",
            "HotelName": "Sublime Cliff Hotel",
            "Description": "Sublime Cliff Hotel is located in the heart of the historic center of Sublime in an extremely vibrant and lively area within short walking distance to the sites and landmarks of the city and is surrounded by the extraordinary beauty of churches, buildings, shops and monuments. Sublime Cliff is part of a lovingly restored 1800 palace.",
            "Description_fr": "Le sublime Cliff Hotel est situé au coeur du centre historique de sublime dans un quartier extrêmement animé et vivant, à courte distance de marche des sites et monuments de la ville et est entouré par l'extraordinaire beauté des églises, des bâtiments, des commerces et Monuments. Sublime Cliff fait partie d'un Palace 1800 restauré avec amour.",
            "Category": "Boutique",
            "Tags": ["concierge", "view", "24-hour front desk service"],
            "ParkingIncluded": true,
            "LastRenovationDate": "1960-02-06T00:00:00Z",
            "Rating": 4.6,
            "Address": {
                "StreetAddress": "7400 San Pedro Ave",
                "City": "San Antonio",
                "StateProvince": "TX",
                "PostalCode": "78216"
            }
        }
    ]
}

与我们使用 indexDefinition 执行的操作类似,我们还需要在 index.js 顶部导入 hotels.json,以便可在我们的 main 函数中访问数据。Similar to what we did with the indexDefinition, we also need to import hotels.json at the top of index.js so that the data can be accessed in our main function.

const hotelData = require('./hotels.json');

为了将数据编入搜索索引中,现在需要创建 SearchClientTo index data into the search index, we now need to create a SearchClient. 虽然 SearchIndexClient 用于创建和管理索引,但 SearchClient 用于上传文档和查询索引。While the SearchIndexClient is used to create and manage an index, the SearchClient is used to upload documents and query the index.

创建 SearchClient 的方法有两种。There are two ways to create a SearchClient. 第一种方法是从头开始创建 SearchClientThe first option is to create a SearchClient from scratch:

 const searchClient = new SearchClient(endpoint, indexName, new AzureKeyCredential(apiKey));

或者,你可使用 SearchIndexClientgetSearchClient() 方法来创建 SearchClientAlternatively, you can use the getSearchClient() method of the SearchIndexClient to create the SearchClient:

const searchClient = indexClient.getSearchClient(indexName);

现在已定义了客户端,需将文档上传到搜索索引。Now that the client is defined, upload the documents into the search index. 这样的话,我们使用 mergeOrUploadDocuments() 方法。该方法将上传文档;如果已存在具有相同密钥的文档,则它将这些文档与现有文档合并。In this case, we use the mergeOrUploadDocuments() method, which will upload the documents or merge them with an existing document if a document with the same key already exists.

console.log('Uploading documents...');
let indexDocumentsResult = await searchClient.mergeOrUploadDocuments(hotelData['value']);

console.log(`Index operations succeeded: ${JSON.stringify(indexDocumentsResult.results[0].succeeded)}`);

使用 node index.js 再次运行程序。Run the program again with node index.js. 应会看到与步骤 1 中显示的消息略有不同的一系列消息。You should see a slightly different set of messages from those you saw in Step 1. 这一次,索引确实存在,而且你会看到一条消息,它显示在应用创建新索引并向其发布数据之前删除此索引。This time, the index does exist, and you should see a message about deleting it before the app creates the new index and posts data to it.

在下一步中运行查询之前,请定义一个函数,使程序等待一秒钟。Before we run the queries in the next step, define a function to have the program wait for one second. 仅出于测试/演示目的这样做,目的是确保索引完成且文档可在索引中用于查询。This is done just for test/demo purposes to ensure the indexing finishes and that the documents are available in the index for our queries.

function sleep(ms) {
    var d = new Date();
    var d2 = null;
    do {
        d2 = new Date();
    } while (d2 - d < ms);
}

若要让程序等待一秒钟,请调用 sleep 函数,如下所示:To have the program wait for one second, call the sleep function like below:

sleep(1000);

3 - 搜索索引3 - Search an index

创建索引并上传文档后,便可将查询发送到索引。With an index created and documents uploaded, you're ready to send queries to the index. 在本部分中,我们将向搜索索引发送 5 个不同的查询,以演示可供你使用的不同查询功能部分。In this section, we'll send five different queries to the search index to demonstrate different pieces of query functionality available to you.

sendQueries() 函数中编写查询,我们将在 main 函数中调用此函数,如下所示:The queries are written in a sendQueries() function that we'll call in the main function as follows:

await sendQueries(searchClient);

使用 searchClientsearch() 方法发送查询。Queries are sent using the search() method of searchClient. 第一个参数是搜索文本,第二个参数是任何附加搜索选项。The first parameter is the search text and the second parameter is any additional search options.

第一个查询会搜索 *,这等效于搜索所有内容并选择索引中的三个字段。The first query searches *, which is equivalent to searching everything and selects three of the fields in the index. 最佳做法是通过 select 仅选择你需要的字段,因为回发不必要的数据可能会增加查询的延迟时间。It's a best practice to only select the fields you need because pulling back unnecessary data can add latency to your queries.

此查询的 searchOptions 还将 includeTotalCount 设置为 true,这将返回找到的匹配结果数。The searchOptions for this query also has includeTotalCount set to true, which will return the number of matching results found.

async function sendQueries(searchClient) {
    console.log('Query #1 - search everything:');
    let searchOptions = {
        includeTotalCount: true,
        select: ["HotelId", "HotelName", "Rating"]
    };

    let searchResults = await searchClient.search("*", searchOptions);
    for await (const result of searchResults.results) {
        console.log(`${JSON.stringify(result.document)}`);
    }
    console.log(`Result count: ${searchResults.count}`);

    // remaining queries go here
}

还应将下述其余查询添加到 sendQueries() 函数。The remaining queries outlined below should also be added to the sendQueries() function. 为了方便阅读,此处将它们分开。They are separated here for readability.

在下一个查询中,我们指定搜索词 "wifi",还包括一个筛选器,以仅返回状态等于 'FL' 的结果。In the next query, we specify the search term "wifi" and also include a filter to only return results where the state is equal to 'FL'. 还会按酒店的 Rating 对结果进行排序。Results are also ordered by the Hotel's Rating.

console.log('Query #2 - Search with filter, orderBy, and select:');
let state = 'FL';
searchOptions = {
    filter: odata`Address/StateProvince eq ${state}`,
    orderBy: ["Rating desc"],
    select: ["HotelId", "HotelName", "Rating"]
};

searchResults = await searchClient.search("wifi", searchOptions);
for await (const result of searchResults.results) {
    console.log(`${JSON.stringify(result.document)}`);
}

接下来,使用 searchFields 参数将搜索限制为单个可搜索字段。Next, the search is limited to a single searchable field using the searchFields parameter. 如果你知道自己只对某些字段中的匹配感兴趣,则很适合使用该选项来提高查询的效率。This is a great option to make your query more efficient if you know you're only interested in matches in certain fields.

console.log('Query #3 - Limit searchFields:');
searchOptions = {
    select: ["HotelId", "HotelName", "Rating"],
    searchFields: ["HotelName"]
};

searchResults = await searchClient.search("sublime cliff", searchOptions);
for await (const result of searchResults.results) {
    console.log(`${JSON.stringify(result.document)}`);
}
console.log();

查询中包含的另一个常见选项是 facetsAnother common option to include in a query is facets. 通过 facet,可在 UI 上构建筛选器,使用户能够轻松地了解可筛选出的值。Facets allow you to build out filters on your UI to make it easy for users to know what values they can filter down to.

console.log('Query #4 - Use facets:');
searchOptions = {
    facets: ["Category"],
    select: ["HotelId", "HotelName", "Rating"],
    searchFields: ["HotelName"]
};

searchResults = await searchClient.search("*", searchOptions);
for await (const result of searchResults.results) {
    console.log(`${JSON.stringify(result.document)}`);
}

最终查询使用 searchClientgetDocument() 方法。The final query uses the getDocument() method of the searchClient. 这样,你就可通过文档的密钥有效地检索文档。This allows you to efficiently retrieve a document by its key.

console.log('Query #5 - Lookup document:');
let documentResult = await searchClient.getDocument(key='3')
console.log(`HotelId: ${documentResult.HotelId}; HotelName: ${documentResult.HotelName}`)

运行示例Run the sample

使用 node index.js 运行程序。Run the program with node index.js. 现在,除上述步骤以外,还会发送查询并将结果写入控制台。Now, in addition to the previous steps, the queries will be sent and the results written to the console.

清理资源Clean up resources

在自己的订阅中操作时,最好在项目结束时确定是否仍需要已创建的资源。When you're working in your own subscription, it's a good idea at the end of a project to identify whether you still need the resources you created. 持续运行资源可能会产生费用。Resources left running can cost you money. 可以逐个删除资源,也可以删除资源组以删除整个资源集。You can delete resources individually or delete the resource group to delete the entire set of resources.

可以使用左侧导航窗格中的“所有资源”或“资源组”链接 ,在门户中查找和管理资源。You can find and manage resources in the portal, using the All resources or Resource groups link in the left-navigation pane.

如果使用的是免费服务,请记住只能设置三个索引、索引器和数据源。If you are using a free service, remember that you are limited to three indexes, indexers, and data sources. 可以在门户中删除单个项目,以不超出此限制。You can delete individual items in the portal to stay under the limit.

后续步骤Next steps

在此 JavaScript 快速入门中,你完成了一系列任务:创建索引、使用文档加载索引,以及运行查询。In this JavaScript quickstart, you worked through a series of tasks to create an index, load it with documents, and run queries.

如果已对 Azure 认知搜索有一定的了解,可以将此教程用作尝试使用建议器(提前键入或自动完成查询)、筛选器和分面导航的跳板。If you already have some background in Azure Cognitive Search, you can use this sample as a springboard for trying suggesters (type-ahead or autocomplete queries), filters, and faceted navigation. 如果你是 Azure 认知搜索的新手,我们建议尝试阅读其他教程,深入了解可以创建哪些内容。If you're new to Azure Cognitive Search, we recommend trying other tutorials to develop an understanding of what you can create. 请访问 文档页 查找更多资源。Visit our documentation page to find more resources.