PrepAway - Latest Free Exam Questions & Answers

Does the solution meet the goal?

You need to import the restaurant data into the Azure Search service by using the Azure Search .NET SDK.

Solution:

1. Create a SearchIndexClient object to connect to the search index
2. Create an IndexBatch that contains the documents which must be added.
3. Call the Documents.Index method of the SearchIndexClient and pass the IndexBatch.

Does the solution meet the goal?

A. Yes

B. No

Explanation:
1. The index needs to be populated. To do this, we will need a SearchIndexClient. There are two ways to obtain one: by constructing it, or by calling Indexes.GetClient on the SearchServiceClient. Here we will use the first method.

2. Create the indexBatch with the documents
Something like:
var hotels = new Hotel[];
{
new Hotel()
{
HotelId = “3”,
BaseRate = 129.99,
Description = “Close to town hall and the river”
}
};

var batch = IndexBatch.Upload(hotels);

3. The next step is to populate the newly-created index
Example:
var batch = IndexBatch.Upload(hotels);

try
{
indexClient.Documents.Index(batch);
}

References:
https://docs.microsoft.com/en-us/azure/search/search-howto-dotnet-sdk


Leave a Reply