Skip to content

Commit

Permalink
samples: improved massage in case of an empty search result (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arakel2811 authored Sep 20, 2022
1 parent 49533bb commit aaec045
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 12 deletions.
6 changes: 5 additions & 1 deletion retail/interactive-tutorials/search/search-simple-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ async function main() {
autoPaginate: false,
});
const searchResponse = response[IResponseParams.ISearchResponse];
console.log('Search result: ', JSON.stringify(searchResponse, null, 4));
if (searchResponse.totalSize === 0) {
console.log('The search operation returned no matching results.');
} else {
console.log('Search result: ', JSON.stringify(searchResponse, null, 4));
}
console.log('Search end');
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ async function main() {
autoPaginate: false,
});
const searchResponse = response[IResponseParams.ISearchResponse];
console.log('Search result: ', JSON.stringify(searchResponse, null, 4));
if (searchResponse.totalSize === 0) {
console.log('The search operation returned no matching results.');
} else {
console.log('Search result: ', JSON.stringify(searchResponse, null, 4));
}
console.log('Search end');
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ async function main() {
autoPaginate: false,
});
const searchResponse = response[IResponseParams.ISearchResponse];
console.log('Search result: ', JSON.stringify(searchResponse, null, 4));
if (searchResponse.totalSize === 0) {
console.log('The search operation returned no matching results.');
} else {
console.log('Search result: ', JSON.stringify(searchResponse, null, 4));
}
console.log('Search end');
};

Expand Down
6 changes: 5 additions & 1 deletion retail/interactive-tutorials/search/search-with-filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ async function main() {
autoPaginate: false,
});
const searchResponse = response[IResponseParams.ISearchResponse];
console.log('Search result: ', JSON.stringify(searchResponse, null, 4));
if (searchResponse.totalSize === 0) {
console.log('The search operation returned no matching results.');
} else {
console.log('Search result: ', JSON.stringify(searchResponse, null, 4));
}
console.log('Search end');
};

Expand Down
6 changes: 5 additions & 1 deletion retail/interactive-tutorials/search/search-with-ordering.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ async function main() {
autoPaginate: false,
});
const searchResponse = response[IResponseParams.ISearchResponse];
console.log('Search result: ', JSON.stringify(searchResponse, null, 4));
if (searchResponse.totalSize === 0) {
console.log('The search operation returned no matching results.');
} else {
console.log('Search result: ', JSON.stringify(searchResponse, null, 4));
}
console.log('Search end');
};

Expand Down
16 changes: 10 additions & 6 deletions retail/interactive-tutorials/search/search-with-pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,16 @@ async function main() {
autoPaginate: false,
});
const searchResponse = response[IResponseParams.ISearchResponse];
console.log('Search result: ', JSON.stringify(searchResponse, null, 4));
pageToken = response[IResponseParams.ISearchResponse].nextPageToken;
console.log(
'Next page token:',
response[IResponseParams.ISearchResponse].nextPageToken
);
if (searchResponse.totalSize === 0) {
console.log('The search operation returned no matching results.');
} else {
console.log('Search result: ', JSON.stringify(searchResponse, null, 4));
pageToken = response[IResponseParams.ISearchResponse].nextPageToken;
console.log(
'Next page token:',
response[IResponseParams.ISearchResponse].nextPageToken
);
}
console.log('Search end');
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ async function main() {
autoPaginate: false,
});
const searchResponse = response[IResponseParams.ISearchResponse];
console.log('Search result: ', JSON.stringify(searchResponse, null, 4));
if (searchResponse.totalSize === 0) {
console.log('The search operation returned no matching results.');
} else {
console.log('Search result: ', JSON.stringify(searchResponse, null, 4));
}
console.log('Search end');
};

Expand Down

0 comments on commit aaec045

Please sign in to comment.