diff --git a/docs/search-core.documentresult.documentscore.md b/docs/search-core.documentresult.documentscore.md
new file mode 100644
index 00000000..8a61cc16
--- /dev/null
+++ b/docs/search-core.documentresult.documentscore.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [@yext/search-core](./search-core.md) > [DocumentResult](./search-core.documentresult.md) > [documentScore](./search-core.documentresult.documentscore.md)
+
+## DocumentResult.documentScore property
+
+The score calculated from whatever document search strategy was used.
+
+Signature:
+
+```typescript
+documentScore: number;
+```
diff --git a/docs/search-core.documentresult.md b/docs/search-core.documentresult.md
new file mode 100644
index 00000000..df1ff79e
--- /dev/null
+++ b/docs/search-core.documentresult.md
@@ -0,0 +1,21 @@
+
+
+[Home](./index.md) > [@yext/search-core](./search-core.md) > [DocumentResult](./search-core.documentresult.md)
+
+## DocumentResult interface
+
+Details about the document and the document search algorithm
+
+Signature:
+
+```typescript
+export interface DocumentResult
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [documentScore](./search-core.documentresult.documentscore.md) | number | The score calculated from whatever document search strategy was used. |
+| [segments](./search-core.documentresult.segments.md) | [Segment](./search-core.segment.md)\[\] | All the relevant segments extracted from the document. |
+
diff --git a/docs/search-core.documentresult.segments.md b/docs/search-core.documentresult.segments.md
new file mode 100644
index 00000000..ee6039c4
--- /dev/null
+++ b/docs/search-core.documentresult.segments.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [@yext/search-core](./search-core.md) > [DocumentResult](./search-core.documentresult.md) > [segments](./search-core.documentresult.segments.md)
+
+## DocumentResult.segments property
+
+All the relevant segments extracted from the document.
+
+Signature:
+
+```typescript
+segments: Segment[];
+```
diff --git a/docs/search-core.md b/docs/search-core.md
index ccbb1740..3ca5a1c9 100644
--- a/docs/search-core.md
+++ b/docs/search-core.md
@@ -63,6 +63,7 @@
| [DisjunctionStaticFilter](./search-core.disjunctionstaticfilter.md) | A static filter composed by combining filters with the logical OR operator. The combined filters can either be field value filters or other disjunction filters. |
| [DisplayableFacet](./search-core.displayablefacet.md) | A [Facet](./search-core.facet.md) which contains extra fields meant to be displayed to the end user. |
| [DisplayableFacetOption](./search-core.displayablefacetoption.md) | A [FacetOption](./search-core.facetoption.md) with extra data meant to be displayed to the end user. |
+| [DocumentResult](./search-core.documentresult.md) | Details about the document and the document search algorithm |
| [EmailDirectAnswer](./search-core.emaildirectanswer.md) | A [BaseFieldValueDirectAnswer](./search-core.basefieldvaluedirectanswer.md) interface with 'email' field type. |
| [Endpoints](./search-core.endpoints.md) | Overrides for the URLs which are used when making requests to the Search API. |
| [FacebookUrlDirectAnswer](./search-core.facebookurldirectanswer.md) | A direct answer for a facebook url field. |
@@ -105,6 +106,7 @@
| [SearchParameterField](./search-core.searchparameterfield.md) | Indicates which entity field to perform the autocomplete request on. |
| [SearchRequest](./search-core.searchrequest.md) | Options for a Search API request. |
| [SearchService](./search-core.searchservice.md) | A service which performs Yext Search. |
+| [Segment](./search-core.segment.md) | A result produced by a document vertical. |
| [ServingConfig](./search-core.servingconfig.md) | The configuration options for getting the endpoints. |
| [Snippet](./search-core.snippet.md) | The section of text where a [FeaturedSnippetDirectAnswer](./search-core.featuredsnippetdirectanswer.md) was found. |
| [SortBy](./search-core.sortby.md) | Represents a criterion that can be used to sort results. |
diff --git a/docs/search-core.result.document.md b/docs/search-core.result.document.md
new file mode 100644
index 00000000..7b181f7b
--- /dev/null
+++ b/docs/search-core.result.document.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [@yext/search-core](./search-core.md) > [Result](./search-core.result.md) > [document](./search-core.result.document.md)
+
+## Result.document property
+
+A relevant document associated with the result. Present for document verticals grouped by Document.
+
+Signature:
+
+```typescript
+document?: DocumentResult;
+```
diff --git a/docs/search-core.result.documents.md b/docs/search-core.result.documents.md
new file mode 100644
index 00000000..d0252799
--- /dev/null
+++ b/docs/search-core.result.documents.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [@yext/search-core](./search-core.md) > [Result](./search-core.result.md) > [documents](./search-core.result.documents.md)
+
+## Result.documents property
+
+All relevant documents associated with the result. Present for document verticals grouped by Entity.
+
+Signature:
+
+```typescript
+documents?: DocumentResult[];
+```
diff --git a/docs/search-core.result.md b/docs/search-core.result.md
index f7df95d7..3368294c 100644
--- a/docs/search-core.result.md
+++ b/docs/search-core.result.md
@@ -19,12 +19,15 @@ export interface Result>
| [description?](./search-core.result.description.md) | string | (Optional) A description of the result. |
| [distance?](./search-core.result.distance.md) | number | (Optional) The distance from the user to the result in meters. |
| [distanceFromFilter?](./search-core.result.distancefromfilter.md) | number | (Optional) The distance from a [AppliedQueryFilter](./search-core.appliedqueryfilter.md) location to the result in meters. |
+| [document?](./search-core.result.document.md) | [DocumentResult](./search-core.documentresult.md) | (Optional) A relevant document associated with the result. Present for document verticals grouped by Document. |
+| [documents?](./search-core.result.documents.md) | [DocumentResult](./search-core.documentresult.md)\[\] | (Optional) All relevant documents associated with the result. Present for document verticals grouped by Entity. |
| [entityType?](./search-core.result.entitytype.md) | string | (Optional) The entity type of the result. |
| [highlightedFields?](./search-core.result.highlightedfields.md) | [HighlightedFields](./search-core.highlightedfields.md) | (Optional) The [highlighted fields](./search-core.highlightedfields.md) emphasized by the api. |
| [id?](./search-core.result.id.md) | string | (Optional) The result ID which depends on the Result Source. |
| [index?](./search-core.result.index.md) | number | (Optional) The index of the result among the other results in the search. |
| [link?](./search-core.result.link.md) | string | (Optional) A hyperlink associated with the result. |
| [name?](./search-core.result.name.md) | string | (Optional) The name of the result. |
-| [rawData](./search-core.result.rawdata.md) | T | Raw entity profile data in the shape of key-value pairs. |
+| [rawData](./search-core.result.rawdata.md) | T | Raw entity profile data in the shape of key-value pairs, or as an array of key-value pairs. |
+| [segment?](./search-core.result.segment.md) | [Segment](./search-core.segment.md) | (Optional) A relevant segment associated with the result. Present for document verticals grouped by Segment. |
| [source](./search-core.result.source.md) | [Source](./search-core.source.md) | Represents the source of a [Result](./search-core.result.md). |
diff --git a/docs/search-core.result.rawdata.md b/docs/search-core.result.rawdata.md
index a7f0b912..08758828 100644
--- a/docs/search-core.result.rawdata.md
+++ b/docs/search-core.result.rawdata.md
@@ -4,7 +4,7 @@
## Result.rawData property
-Raw entity profile data in the shape of key-value pairs.
+Raw entity profile data in the shape of key-value pairs, or as an array of key-value pairs.
Signature:
diff --git a/docs/search-core.result.segment.md b/docs/search-core.result.segment.md
new file mode 100644
index 00000000..e7b561ce
--- /dev/null
+++ b/docs/search-core.result.segment.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [@yext/search-core](./search-core.md) > [Result](./search-core.result.md) > [segment](./search-core.result.segment.md)
+
+## Result.segment property
+
+A relevant segment associated with the result. Present for document verticals grouped by Segment.
+
+Signature:
+
+```typescript
+segment?: Segment;
+```
diff --git a/docs/search-core.segment.md b/docs/search-core.segment.md
new file mode 100644
index 00000000..c8755534
--- /dev/null
+++ b/docs/search-core.segment.md
@@ -0,0 +1,21 @@
+
+
+[Home](./index.md) > [@yext/search-core](./search-core.md) > [Segment](./search-core.segment.md)
+
+## Segment interface
+
+A result produced by a document vertical.
+
+Signature:
+
+```typescript
+export interface Segment
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [score](./search-core.segment.score.md) | number | The similarity score of the segment from 0 to 1 |
+| [text](./search-core.segment.text.md) | string | The value of the segment as plain text. |
+
diff --git a/docs/search-core.segment.score.md b/docs/search-core.segment.score.md
new file mode 100644
index 00000000..52919b8a
--- /dev/null
+++ b/docs/search-core.segment.score.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [@yext/search-core](./search-core.md) > [Segment](./search-core.segment.md) > [score](./search-core.segment.score.md)
+
+## Segment.score property
+
+The similarity score of the segment from 0 to 1
+
+Signature:
+
+```typescript
+score: number;
+```
diff --git a/docs/search-core.segment.text.md b/docs/search-core.segment.text.md
new file mode 100644
index 00000000..1eab48f6
--- /dev/null
+++ b/docs/search-core.segment.text.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [@yext/search-core](./search-core.md) > [Segment](./search-core.segment.md) > [text](./search-core.segment.text.md)
+
+## Segment.text property
+
+The value of the segment as plain text.
+
+Signature:
+
+```typescript
+text: string;
+```
diff --git a/docs/search-core.source.md b/docs/search-core.source.md
index 23a39cf7..6dc1c3cd 100644
--- a/docs/search-core.source.md
+++ b/docs/search-core.source.md
@@ -19,6 +19,7 @@ export declare enum Source
| Algolia | "ALGOLIA"
| The result is from Algolia. |
| Bing | "BING_CSE"
| The result is from Bing Search Engine. |
| Custom | "CUSTOM_SEARCHER"
| The result was from a custom source. |
+| DocumentVertical | "DOCUMENT_VERTICAL"
| The result is from a document vertical. |
| Google | "GOOGLE_CSE"
| The result is from Google Custom Search Engine. |
| KnowledgeManager | "KNOWLEDGE_MANAGER"
| The result is from a Knowledge Graph. |
| Zendesk | "ZENDESK"
| The result is from Zendesk. |
diff --git a/etc/search-core.api.md b/etc/search-core.api.md
index 2d46a534..5a9823ed 100644
--- a/etc/search-core.api.md
+++ b/etc/search-core.api.md
@@ -255,6 +255,12 @@ export interface DisplayableFacetOption extends FacetOption {
selected: boolean;
}
+// @public
+export interface DocumentResult {
+ documentScore: number;
+ segments: Segment[];
+}
+
// @public
export interface EmailDirectAnswer extends BaseFieldValueDirectAnswer {
// (undocumented)
@@ -594,6 +600,8 @@ export interface Result> {
description?: string;
distance?: number;
distanceFromFilter?: number;
+ document?: DocumentResult;
+ documents?: DocumentResult[];
entityType?: string;
highlightedFields?: HighlightedFields;
id?: string;
@@ -601,6 +609,7 @@ export interface Result> {
link?: string;
name?: string;
rawData: T;
+ segment?: Segment;
source: Source;
}
@@ -681,6 +690,12 @@ export interface SearchService {
verticalSearch(request: VerticalSearchRequest): Promise;
}
+// @public
+export interface Segment {
+ score: number;
+ text: string;
+}
+
// @public
export interface ServingConfig {
cloudRegion?: CloudRegion;
@@ -715,6 +730,7 @@ export enum Source {
Algolia = "ALGOLIA",
Bing = "BING_CSE",
Custom = "CUSTOM_SEARCHER",
+ DocumentVertical = "DOCUMENT_VERTICAL",
Google = "GOOGLE_CSE",
KnowledgeManager = "KNOWLEDGE_MANAGER",
Zendesk = "ZENDESK"
diff --git a/package-lock.json b/package-lock.json
index b2e49983..f7b379f4 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@yext/search-core",
- "version": "2.4.1",
+ "version": "2.5.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@yext/search-core",
- "version": "2.4.1",
+ "version": "2.5.0",
"license": "BSD-3-Clause",
"dependencies": {
"@babel/runtime-corejs3": "^7.12.5",
diff --git a/package.json b/package.json
index 646dc698..97c2305e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@yext/search-core",
- "version": "2.4.1",
+ "version": "2.5.0",
"description": "Typescript Networking Library for the Yext Search API",
"main": "./dist/commonjs/src/index.js",
"module": "./dist/esm/src/index.js",
diff --git a/src/models/index.ts b/src/models/index.ts
index 2c095d9c..369e4a4f 100644
--- a/src/models/index.ts
+++ b/src/models/index.ts
@@ -82,6 +82,8 @@ export { VerticalSearchResponse } from './searchservice/response/VerticalSearchR
export { Snippet } from './searchservice/response/Snippet';
export { ErrorType } from './searchservice/response/ErrorType';
export { FailedVertical } from './searchservice/response/FailedVertical';
+export { Segment } from './searchservice/response/Segment';
+export { DocumentResult } from './searchservice/response/DocumentResult';
// Search service common models
export { Matcher } from './searchservice/common/Matcher';
diff --git a/src/models/searchservice/response/DocumentResult.ts b/src/models/searchservice/response/DocumentResult.ts
new file mode 100644
index 00000000..248a35b2
--- /dev/null
+++ b/src/models/searchservice/response/DocumentResult.ts
@@ -0,0 +1,13 @@
+import { Segment } from './Segment';
+
+/**
+ * Details about the document and the document search algorithm
+ *
+ * @public
+ */
+export interface DocumentResult {
+ /** The score calculated from whatever document search strategy was used. */
+ documentScore: number,
+ /** All the relevant segments extracted from the document. */
+ segments: Segment[]
+}
\ No newline at end of file
diff --git a/src/models/searchservice/response/Result.ts b/src/models/searchservice/response/Result.ts
index c7996647..047b0558 100644
--- a/src/models/searchservice/response/Result.ts
+++ b/src/models/searchservice/response/Result.ts
@@ -1,5 +1,7 @@
import { HighlightedFields } from './HighlightedFields';
import { Source } from './Source';
+import { Segment } from './Segment';
+import { DocumentResult } from './DocumentResult';
/**
* An individual search result.
@@ -7,7 +9,7 @@ import { Source } from './Source';
* @public
*/
export interface Result> {
- /** Raw entity profile data in the shape of key-value pairs. */
+ /** Raw entity profile data in the shape of key-value pairs, or as an array of key-value pairs. */
rawData: T,
/** {@inheritDoc Source} */
source: Source,
@@ -39,5 +41,18 @@ export interface Result> {
/** The {@link HighlightedFields | highlighted fields} emphasized by the api. */
highlightedFields?: HighlightedFields,
/** The entity type of the result. */
- entityType?: string
+ entityType?: string,
+ /** A relevant segment associated with the result. Present for document verticals grouped by
+ * Segment. */
+ segment?: Segment,
+ /**
+ * A relevant document associated with the result. Present for document verticals grouped by
+ * Document.
+ */
+ document?: DocumentResult,
+ /**
+ * All relevant documents associated with the result. Present for document verticals grouped by
+ * Entity.
+ */
+ documents?: DocumentResult[]
}
\ No newline at end of file
diff --git a/src/models/searchservice/response/Segment.ts b/src/models/searchservice/response/Segment.ts
new file mode 100644
index 00000000..bc8c5c8a
--- /dev/null
+++ b/src/models/searchservice/response/Segment.ts
@@ -0,0 +1,11 @@
+/**
+ * A result produced by a document vertical.
+ *
+ * @public
+ */
+export interface Segment {
+ /** The value of the segment as plain text. */
+ text: string,
+ /** The similarity score of the segment from 0 to 1 */
+ score: number
+}
\ No newline at end of file
diff --git a/src/models/searchservice/response/Source.ts b/src/models/searchservice/response/Source.ts
index cdd8833f..ddbebe9d 100644
--- a/src/models/searchservice/response/Source.ts
+++ b/src/models/searchservice/response/Source.ts
@@ -15,5 +15,7 @@ export enum Source {
/** The result is from Algolia. */
Algolia = 'ALGOLIA',
/** The result was from a custom source. */
- Custom = 'CUSTOM_SEARCHER'
+ Custom = 'CUSTOM_SEARCHER',
+ /** The result is from a document vertical. */
+ DocumentVertical = 'DOCUMENT_VERTICAL',
}
\ No newline at end of file
diff --git a/src/transformers/searchservice/ResultsFactory.ts b/src/transformers/searchservice/ResultsFactory.ts
index c4025336..944e1c4d 100644
--- a/src/transformers/searchservice/ResultsFactory.ts
+++ b/src/transformers/searchservice/ResultsFactory.ts
@@ -24,6 +24,8 @@ export class ResultsFactory {
return this.fromZendeskSearchEngine(result, resultIndex);
case Source.Algolia:
return this.fromAlgoliaSearchEngine(result, resultIndex);
+ case Source.DocumentVertical:
+ return this.fromDocumentVertical(result, resultIndex);
default:
return this.fromCustomSource(result, resultIndex);
}
@@ -47,6 +49,22 @@ export class ResultsFactory {
};
}
+ private static fromDocumentVertical(result: any, index: number): Result {
+ const rawData = result.data ?? result;
+ return {
+ rawData: rawData,
+ source: Source.DocumentVertical,
+ name: rawData.name,
+ description: rawData.description,
+ link: rawData.website,
+ id: rawData.id,
+ index: index,
+ segment: result.segment,
+ document: result.document,
+ documents: result.documents
+ };
+ }
+
private static fromGoogleCustomSearchEngine(result: any, index: number): Result {
const rawData = result.data ?? result;
return {