Quickstart: Use the Bing Entity Search JavaScript client library
Use this quickstart to begin searching for entities with the Bing Entity Search client library for JavaScript. While Bing Entity Search has a REST API compatible with most programming languages, the client library provides an easy way to integrate the service into your applications. The source code for this sample can be found on GitHub.
Prerequisites
The latest version of Node.js.
To install the Bing Entity Search SDK:
- Run
npm install ms-rest-azure
in your development environment. - Run
npm install @azure/cognitiveservices-entitysearch
in your development environment.
Create and initialize the application
Create a new JavaScript file in your favorite IDE or editor, and add the following requirements.
const CognitiveServicesCredentials = require('ms-rest-azure').CognitiveServicesCredentials; const EntitySearchAPIClient = require('@azure/cognitiveservices-entitysearch');
Create an instance of
CognitiveServicesCredentials
using your subscription key. Then create an instance of the search client with it.let credentials = new CognitiveServicesCredentials('YOUR-ACCESS-KEY'); let entitySearchApiClient = new EntitySearchAPIClient(credentials);
Send a request and receive a response
Send an entities search request with
entitiesOperations.search()
. After receiving a response, print out thequeryContext
, number of returned results, and the description of the first result.entitySearchApiClient.entitiesOperations.search('seahawks').then((result) => { console.log(result.queryContext); console.log(result.entities.value); console.log(result.entities.value[0].description); }).catch((err) => { throw err; });
Next steps
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기