Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master (v2.5.3) into develop #276

Merged
merged 3 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions docs/search-core.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ export declare enum Source

| Member | Value | Description |
| --- | --- | --- |
| Algolia | <code>&quot;ALGOLIA&quot;</code> | The result is from Algolia. |
| Bing | <code>&quot;BING_CSE&quot;</code> | The result is from Bing Search Engine. |
| Custom | <code>&quot;CUSTOM_SEARCHER&quot;</code> | The result was from a custom source. |
| DocumentVertical | <code>&quot;DOCUMENT_VERTICAL&quot;</code> | The result is from a document vertical. |
| FunctionVertical | <code>&quot;FUNCTION_VERTICAL&quot;</code> | The result is from a function vertical. |
| Google | <code>&quot;GOOGLE_CSE&quot;</code> | The result is from Google Custom Search Engine. |
| KnowledgeManager | <code>&quot;KNOWLEDGE_MANAGER&quot;</code> | The result is from a Knowledge Graph. |
| Zendesk | <code>&quot;ZENDESK&quot;</code> | The result is from Zendesk. |

5 changes: 1 addition & 4 deletions etc/search-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -750,14 +750,11 @@ export enum SortType {

// @public
export enum Source {
Algolia = "ALGOLIA",
Bing = "BING_CSE",
Custom = "CUSTOM_SEARCHER",
DocumentVertical = "DOCUMENT_VERTICAL",
FunctionVertical = "FUNCTION_VERTICAL",
Google = "GOOGLE_CSE",
KnowledgeManager = "KNOWLEDGE_MANAGER",
Zendesk = "ZENDESK"
KnowledgeManager = "KNOWLEDGE_MANAGER"
}

// @public
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.3",
"version": "2.6.0-beta.4",
"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: 1 addition & 7 deletions src/models/searchservice/response/Source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,10 @@ export enum Source {
KnowledgeManager = 'KNOWLEDGE_MANAGER',
/** The result is from Google Custom Search Engine. */
Google = 'GOOGLE_CSE',
/** The result is from Bing Search Engine. */
Bing = 'BING_CSE',
/** The result is from Zendesk. */
Zendesk = 'ZENDESK',
/** The result is from Algolia. */
Algolia = 'ALGOLIA',
/** The result was from a custom source. */
Custom = 'CUSTOM_SEARCHER',
/** The result is from a document vertical. */
DocumentVertical = 'DOCUMENT_VERTICAL',
/** The result is from a function vertical. */
FunctionVertical = 'FUNCTION_VERTICAL',
}
}
41 changes: 0 additions & 41 deletions src/transformers/searchservice/ResultsFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ export class ResultsFactory {
return this.fromKnowledgeManager(result, resultIndex);
case Source.Google:
return this.fromGoogleCustomSearchEngine(result, resultIndex);
case Source.Bing:
return this.fromBingCustomSearchEngine(result, resultIndex);
case Source.Zendesk:
return this.fromZendeskSearchEngine(result, resultIndex);
case Source.Algolia:
return this.fromAlgoliaSearchEngine(result, resultIndex);
case Source.DocumentVertical:
return this.fromDocumentVertical(result, resultIndex);
case Source.FunctionVertical:
Expand Down Expand Up @@ -79,41 +73,6 @@ export class ResultsFactory {
};
}

private static fromBingCustomSearchEngine(result: any, index: number): Result {
const rawData = result.data ?? result;
return {
rawData: rawData,
source: Source.Bing,
index: index,
name: rawData.name,
description: rawData.snippet,
link: rawData.url
};
}

private static fromZendeskSearchEngine(result: any, index: number): Result {
const rawData = result.data ?? result;
return {
rawData: rawData,
source: Source.Zendesk,
index: index,
name: rawData.title,
description: rawData.snippet,
link: rawData.html_url
};
}

private static fromAlgoliaSearchEngine(result: any, index: number): Result {
const rawData = result.data ?? result;
return {
rawData: rawData,
source: Source.Algolia,
index: index,
name: rawData.name,
id: rawData.objectID
};
}

private static fromCustomSource(result: any, index: number): Result {
return this.fromCustomDataHelper(result, index, Source.Custom);
}
Expand Down
81 changes: 1 addition & 80 deletions tests/transformers/searchservice/ResultsFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,59 +42,6 @@ it('properly transforms Knowledge Graph results', () => {
expect(expectedResults).toMatchObject(actualResults);
});

it('properly transforms Zendesk results', () => {
const zendeskData = [{
html_url: 'https://help.yext.com/',
id: 8273729837,
snippet: 'Enter the Preview link into the text box.',
title: 'Add Custom Schema.org Markup',
}];

const expectedResults = [{
description: 'Enter the Preview link into the text box.',
index: 1,
link: 'https://help.yext.com/',
name: 'Add Custom Schema.org Markup',
rawData: {
html_url: 'https://help.yext.com/',
id: 8273729837,
snippet: 'Enter the Preview link into the text box.',
title: 'Add Custom Schema.org Markup',
},
source: 'ZENDESK',
}];

const actualResults = ResultsFactory.create(zendeskData, Source.Zendesk);
expect(expectedResults).toMatchObject(actualResults);
});

it('properly transforms Algolia results', () => {
const algoliaData = [{
location: 'Atlanta',
logoUrl: 'Hawks_Atlanta.gif',
name: 'Hawks',
objectID: '49688642',
score: 595.5714285714286
}];

const expectedResults = [{
id: '49688642',
index: 1,
name: 'Hawks',
rawData: {
location: 'Atlanta',
logoUrl: 'Hawks_Atlanta.gif',
name: 'Hawks',
objectID: '49688642',
score: 595.5714285714286,
},
source: 'ALGOLIA',
}];

const actualResults = ResultsFactory.create(algoliaData, Source.Algolia);
expect(expectedResults).toMatchObject(actualResults);
});

it('properly transforms Google Custom Search results', () => {
const googleData = [{
displayLink: 'www.yext.com',
Expand All @@ -121,32 +68,6 @@ it('properly transforms Google Custom Search results', () => {
expect(expectedResults).toMatchObject(actualResults);
});

it('properly transforms Bing search results', () => {
const bingData = [{
displayUrl: 'www.yext.com/support',
name: 'Yext support',
snippet: 'Get help from Yext',
url: 'http://www.yext.com/support'
}];

const expectedResults = [{
description: 'Get help from Yext',
index: 1,
link: 'http://www.yext.com/support',
name: 'Yext support',
rawData: {
displayUrl: 'www.yext.com/support',
name: 'Yext support',
snippet: 'Get help from Yext',
url: 'http://www.yext.com/support',
},
source: 'BING_CSE',
}];

const actualResults = ResultsFactory.create(bingData, Source.Bing);
expect(expectedResults).toMatchObject(actualResults);
});

it('properly transforms backend results from custom source', () => {
const genericData = [{
data: {
Expand Down Expand Up @@ -217,4 +138,4 @@ it('properly transforms backend results from function vertical', () => {

const actualResults = ResultsFactory.create(genericData, Source.FunctionVertical);
expect(expectedResults).toMatchObject(actualResults);
});
});
Loading