Skip to content

Commit 9cb043d

Browse files
committed
Cleanup
1 parent 7e7e117 commit 9cb043d

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

quickstart/AzureSearchClient.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class AzureSearchClient {
55

66
async indexExistsAsync() {
77
console.log("\n Checking if index exists...");
8-
const endpoint = this.searchServiceHelper.getIndexExistsUrl();
8+
const endpoint = this.searchServiceHelper.getIndexUrl();
99
const response = await this.searchServiceHelper.request(endpoint, "GET", null);
1010
// Success has a few likely status codes: 200 or 204 (No Content), but accept all in 200 range...
1111
const exists = response.status >= 200 && response.status < 300;
@@ -14,21 +14,21 @@ class AzureSearchClient {
1414

1515
async deleteIndexAsync() {
1616
console.log("\n Deleting existing index...");
17-
const endpoint = this.searchServiceHelper.getIndexExistsUrl();
17+
const endpoint = this.searchServiceHelper.getIndexUrl();
1818
const response = await this.searchServiceHelper.request(endpoint, "DELETE");
1919
this.searchServiceHelper.throwOnHttpError(response);
2020
return this;
2121
}
2222

2323
async createIndexAsync(definition) {
2424
console.log("\n Creating index...");
25-
const endpoint = this.searchServiceHelper.getCreateIndexUrl();
25+
const endpoint = this.searchServiceHelper.getIndexUrl();
2626
const response = await this.searchServiceHelper.request(endpoint, "PUT", definition);
2727
this.searchServiceHelper.throwOnHttpError(response);
2828
return this;
2929
}
3030

31-
async loadDataAsync(hotelsData) {
31+
async postDataAsync(hotelsData) {
3232
console.log("\n Adding hotel data...");
3333
const endpoint = this.searchServiceHelper.getPostDataUrl();
3434
const response = await this.searchServiceHelper.request(endpoint,"POST", hotelsData);

quickstart/SearchServiceHelper.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,22 @@ class SearchServiceHelper {
88
this.apiVersion = '2019-05-06';
99
}
1010

11-
_indexUrl() { return `https://${this.searchServiceName}.search.windows.net/indexes/${this.indexName}?api-version=${this.apiVersion}`; }
11+
getIndexUrl() { return `https://${this.searchServiceName}.search.windows.net/indexes/${this.indexName}?api-version=${this.apiVersion}`; }
1212

13-
getIndexExistsUrl() { return this._indexUrl(); }
14-
getCreateIndexUrl() { return this._indexUrl(); }
15-
1613
getPostDataUrl() { return `https://${this.searchServiceName}.search.windows.net/indexes/${this.indexName}/docs/index?api-version=${this.apiVersion}`; }
1714

1815
getSearchUrl(searchTerm) { return `https://${this.searchServiceName}.search.windows.net/indexes/${this.indexName}/docs?api-version=${this.apiVersion}&search=${searchTerm}&searchMode=all`; }
1916

2017

2118
request(url, method, bodyJson = null) {
19+
// Uncomment the following for request details:
20+
/*
2221
console.log(`\n${method} ${url}`);
23-
22+
if (bodyJson !== null) {
23+
console.log(`\ncontent: ${JSON.stringify(bodyJson, null, 4)}`);
24+
}
25+
*/
26+
2427
const headers = {
2528
'content-type' : 'application/json',
2629
'api-key' : this.apiKey

quickstart/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const run = async () => {
5757
const indexDefinition = require('./hotels_quickstart_index.json');
5858
await client.createIndexAsync(indexDefinition);
5959
await sleep(2000);
60-
await client.loadDataAsync(hotelData);
60+
await client.postDataAsync(hotelData);
6161
await sleep(5000);
6262
await doQueries(client);
6363
} catch (x) {

0 commit comments

Comments
 (0)