Skip to content

Commit

Permalink
Version 1.17.4
Browse files Browse the repository at this point in the history
Fixes

Ensure segments returned in results are maintained Update Result object to maintain segment field #1892
Allow document vertical results to have their data formatted Update Result object to maintain segment field #1892
  • Loading branch information
Fondryext authored Aug 7, 2024
2 parents e4d8856 + 4f883a5 commit 2bf2b35
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 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/answers-search-ui",
"version": "1.17.3",
"version": "1.17.4",
"description": "Javascript Search Programming Interface",
"main": "dist/answers-umd.js",
"repository": {
Expand Down
7 changes: 6 additions & 1 deletion src/core/models/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ export default class Result {
* @type {number}
*/
this.distanceFromFilter = data.distanceFromFilter || null;
/**
* In the case of a Document Vertical result grouped by segments, the formatted segment data
* @type {Object}
*/
this.segment = data.segment || null;
}

/**
Expand Down Expand Up @@ -141,7 +146,7 @@ export default class Result {
segment: result.segment
};

if (result.source !== 'KNOWLEDGE_MANAGER') {
if (result.source !== 'KNOWLEDGE_MANAGER' && result.source !== 'DOCUMENT_VERTICAL') {
return new Result(resultData);
}

Expand Down
16 changes: 14 additions & 2 deletions tests/core/models/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ it('constructs a result from an answers-core result', () => {
}]
}
},
entityType: 'ce_fruit'
entityType: 'ce_fruit',
segment: {
text: 'Some segment ',
score: 0.27316594,
segmentNumber: 3,
fieldId: 'c_segmentField'
}
};

const expectedResult = {
Expand All @@ -37,7 +43,13 @@ it('constructs a result from an answers-core result', () => {
link: 'www.yext.com',
id: 2,
distance: 20,
distanceFromFilter: 30
distanceFromFilter: 30,
segment: {
text: 'Some segment ',
score: 0.27316594,
segmentNumber: 3,
fieldId: 'c_segmentField'
}
};

const actualResult = Result.fromCore(coreResult);
Expand Down

0 comments on commit 2bf2b35

Please sign in to comment.