Skip to content

Commit

Permalink
make queryDurationMillis field optional in VerticalResults (#266)
Browse files Browse the repository at this point in the history
J=CLIP-1318
TEST=auto,manual

ran `npm run test`. Tested this change together with the rest of the sdk to confirm that gda is executed successfully after executeVerticalQuery finishes.
  • Loading branch information
anguyen-yext2 authored and Fondryext committed Dec 9, 2024
1 parent fedef35 commit 7026542
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 29 deletions.
11 changes: 11 additions & 0 deletions docs/search-core.verticalresults.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@ export interface VerticalResults

## Properties

<<<<<<< HEAD
<table><thead><tr><th>
=======
| Property | Type | Description |
| --- | --- | --- |
| [appliedQueryFilters](./search-core.verticalresults.appliedqueryfilters.md) | [AppliedQueryFilter](./search-core.appliedqueryfilter.md)<!-- -->\[\] | A array of [AppliedQueryFilter](./search-core.appliedqueryfilter.md)<!-- -->s which were applied to the vertical results. |
| [queryDurationMillis?](./search-core.verticalresults.querydurationmillis.md) | number | <i>(Optional)</i> The duration of the query in milliseconds |
| [results](./search-core.verticalresults.results.md) | [Result](./search-core.result.md)<!-- -->\[\] | An array of search [Result](./search-core.result.md)<!-- -->s for the vertical. |
| [resultsCount](./search-core.verticalresults.resultscount.md) | number | The total number of results within the vertical. |
| [source](./search-core.verticalresults.source.md) | [Source](./search-core.source.md) | Represents the source of a [Result](./search-core.result.md)<!-- -->. |
| [verticalKey](./search-core.verticalresults.verticalkey.md) | string | The vertical key associated with the vertical results. |
>>>>>>> 8035fcc (make `queryDurationMillis` field optional in VerticalResults (#266))

Property

Expand Down
9 changes: 7 additions & 2 deletions docs/search-core.verticalresults.querydurationmillis.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@

## VerticalResults.queryDurationMillis property

The duration of the query in milliseconds.
The duration of the query in milliseconds

**Signature:**

```typescript
queryDurationMillis: number;
queryDurationMillis?: number;
```

## Remarks

This is present in a universal search but not in a vertical search.

2 changes: 1 addition & 1 deletion etc/search-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ export interface VerticalAutocompleteRequest extends SearchRequest {
// @public
export interface VerticalResults {
appliedQueryFilters: AppliedQueryFilter[];
queryDurationMillis: number;
queryDurationMillis?: number;
results: Result[];
resultsCount: number;
source: Source;
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yext/search-core",
"version": "2.6.0-beta",
"version": "2.6.0-beta.2",
"description": "Typescript Networking Library for the Yext Search API",
"main": "./dist/commonjs/src/index.js",
"module": "./dist/esm/src/index.js",
Expand Down
8 changes: 6 additions & 2 deletions src/models/searchservice/response/VerticalResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ import { Source } from './Source';
export interface VerticalResults {
/** A array of {@link AppliedQueryFilter}s which were applied to the vertical results. */
appliedQueryFilters: AppliedQueryFilter[],
/** The duration of the query in milliseconds. */
queryDurationMillis: number,
/** The duration of the query in milliseconds
*
* @remarks
* This is present in a universal search but not in a vertical search.
*/
queryDurationMillis?: number,
/** An array of search {@link Result}s for the vertical. */
results: Result[],
/**
Expand Down
44 changes: 23 additions & 21 deletions tests/infra/GenerativeDirectAnswerServiceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const defaultEndpoints: Required<Endpoints> = new EndpointsFactory().getEndpoint

const mockVerticalResults = [{
'appliedQueryFilters': [],
'queryDurationMillis': 141,
'results': [
{
'distance': 608,
Expand Down Expand Up @@ -142,28 +141,31 @@ it('additionalQueryParams are passed through', async () => {
}));
});

const mockUniversalResults = [mockVerticalResults, {
'appliedQueryFilters': [],
'queryDurationMillis': 313,
'results': [
{
'id': '4038721755206544552',
'index': 3,
'name': 'How do I create a Very Special Event?',
'rawData': {
const mockUniversalResults = [
{ ...mockVerticalResults, 'queryDurationMillis': 141 },
{
'appliedQueryFilters': [],
'queryDurationMillis': 313,
'results': [
{
'id': '4038721755206544552',
'index': 3,
'name': 'How do I create a Very Special Event?',
'question': 'How do I create a Very Special Event?',
'type': 'faq',
'uid': '8367352'
},
'source': 'CUSTOM_SEARCHER'
}
],
'resultsCount': 1,
'source': 'DOCUMENT_VERTICAL',
'verticalKey': 'faq_vector'
}];
'rawData': {
'id': '4038721755206544552',
'name': 'How do I create a Very Special Event?',
'question': 'How do I create a Very Special Event?',
'type': 'faq',
'uid': '8367352'
},
'source': 'CUSTOM_SEARCHER'
}
],
'resultsCount': 1,
'source': 'DOCUMENT_VERTICAL',
'verticalKey': 'faq_vector'
}
];

const gdaRequestUniversalResults: GenerativeDirectAnswerRequest = {
searchId: 'testSeachId',
Expand Down

0 comments on commit 7026542

Please sign in to comment.