Skip to content

Commit

Permalink
ksearch: remove Zendesk/Algolia/Bing
Browse files Browse the repository at this point in the history
These three backend types are no longer used/supported,
so this PR removes them and their associated code.

J=WAT-4331
TEST=auto

Updated and ran tests
  • Loading branch information
Fondryext committed Sep 6, 2024
1 parent 09b19f5 commit f3c6747
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 131 deletions.
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.5.2",
"version": "2.5.3",
"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,14 +8,8 @@ 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',
}
}
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);
default:
Expand Down Expand Up @@ -77,41 +71,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 {
const rawData = result.data ?? result;
return {
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 @@ -183,4 +104,4 @@ it('properly transforms backend results from custom source', () => {

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

0 comments on commit f3c6747

Please sign in to comment.