Skip to content

Commit

Permalink
Merge 20dafe0 into e7f7462
Browse files Browse the repository at this point in the history
  • Loading branch information
oshi97 authored Mar 23, 2023
2 parents e7f7462 + 20dafe0 commit 2f02435
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/search-core.autocompleteresult.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface AutocompleteResult
| [filter?](./search-core.autocompleteresult.filter.md) | [FieldValueFilter](./search-core.fieldvaluefilter.md) | <i>(Optional)</i> A filter applied to the autocomplete response. |
| [key?](./search-core.autocompleteresult.key.md) | string | <i>(Optional)</i> The fieldId which corresponds to the AutocompleteResult value. |
| [matchedSubstrings?](./search-core.autocompleteresult.matchedsubstrings.md) | { length: number; offset: number; }\[\] | <i>(Optional)</i> An array of substrings which overlap with the autocomplete input. |
| [queryIntents](./search-core.autocompleteresult.queryintents.md) | [SearchIntent](./search-core.searchintent.md)<!-- -->\[\] | [SearchIntent](./search-core.searchintent.md)<!-- -->s corresponding to the autocomplete result. |
| [relatedItem?](./search-core.autocompleteresult.relateditem.md) | [Result](./search-core.result.md) | <i>(Optional)</i> An entity that corresponds to the autocomplete result. |
| [value](./search-core.autocompleteresult.value.md) | string | The value of an autocomplete suggestion. |
| [verticalKeys?](./search-core.autocompleteresult.verticalkeys.md) | string\[\] | <i>(Optional)</i> Any vertical keys associated with a prompt. This only shows up on universal autocomplete requests. |
Expand Down
13 changes: 13 additions & 0 deletions docs/search-core.autocompleteresult.queryintents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@yext/search-core](./search-core.md) &gt; [AutocompleteResult](./search-core.autocompleteresult.md) &gt; [queryIntents](./search-core.autocompleteresult.queryintents.md)

## AutocompleteResult.queryIntents property

[SearchIntent](./search-core.searchintent.md)<!-- -->s corresponding to the autocomplete result.

<b>Signature:</b>

```typescript
queryIntents: SearchIntent[];
```
1 change: 1 addition & 0 deletions etc/search-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export interface AutocompleteResult {
length: number;
offset: number;
}[];
queryIntents: SearchIntent[];
relatedItem?: Result;
value: string;
verticalKeys?: string[];
Expand Down
6 changes: 5 additions & 1 deletion src/models/autocompleteservice/AutocompleteResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,9 @@ export interface AutocompleteResult {
* Any vertical keys associated with a prompt.
* This only shows up on universal autocomplete requests.
**/
verticalKeys?: string[]
verticalKeys?: string[],
/**
* {@link SearchIntent}s corresponding to the autocomplete result.
*/
queryIntents: SearchIntent[]
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export function createAutocompleteResponse(data: any): AutocompleteResponse {

const response = data.response;
const responseResults = response.results.map(createAutocompleteResult);
const inputIntents = response.input ? response.input.queryIntents : [];
const inputIntents = response.input?.queryIntents ?? [];

return {
results: responseResults,
queryId: response.queryId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function createAutocompleteResult(result: any): AutocompleteResult {
matchedSubstrings: result.matchedSubstrings || [],
value: result.value,
relatedItem: relatedItem,
verticalKeys: result.verticalKeys
verticalKeys: result.verticalKeys,
queryIntents: result.queryIntents ?? []
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ describe('AutocompleteResponse', () => {
results: [
{
value: 'salesforce',
queryIntents: [
SearchIntent.NearMe
],
matchedSubstrings: [
{
offset: 0,
Expand All @@ -33,6 +36,7 @@ describe('AutocompleteResponse', () => {
results: [
{
value: 'Virginia Beach',
queryIntents: [],
matchedSubstrings: [
{
offset: 0,
Expand Down Expand Up @@ -77,6 +81,7 @@ describe('AutocompleteResponse', () => {
fieldId: 'name'
},
key: 'name',
queryIntents: [],
relatedItem: {
rawData: {
mock: 'data'
Expand Down Expand Up @@ -110,6 +115,7 @@ describe('AutocompleteResponse', () => {
fieldId: 'name2'
},
key: 'name',
queryIntents: [],
relatedItem: {
rawData: {
mock: 'data2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('AutocompleteResult', () => {
const expectedResult = {
key: 'key',
value: 'salesforce',
queryIntents: [],
matchedSubstrings: [
{
offset: 0,
Expand Down Expand Up @@ -69,6 +70,7 @@ describe('AutocompleteResult', () => {
fieldId: 'name'
},
key: 'name',
queryIntents: [],
relatedItem: {
rawData: {
mock: 'data'
Expand Down Expand Up @@ -106,6 +108,7 @@ describe('AutocompleteResult', () => {
fieldId: 'name'
},
key: 'name',
queryIntents: [],
matchedSubstrings: [
{
offset: 0,
Expand Down

0 comments on commit 2f02435

Please sign in to comment.