Skip to content

Commit

Permalink
feat: change neuralScore position in result (#136)
Browse files Browse the repository at this point in the history
* feat: change neuralScore position in result

Positioning the neural and feature scores next to the index score and score fields is more intuitive than having it at the bottom of the object.

* bump package to 2.8.2
  • Loading branch information
jkaho authored Jan 18, 2022
1 parent 74a3f42 commit 932a075
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@sajari/sdk-js",
"description": "Sajari JavaScript SDK",
"version": "2.8.1",
"version": "2.8.2",
"main": "dist/index.js",
"umd:main": "dist/sajarisdk.umd.production.js",
"module": "dist/sajarisdk.esm.production.js",
Expand Down
26 changes: 13 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,12 @@ class QueryPipeline extends EventEmitter {

return {
indexScore,
...(neuralScore && { neuralScore }),
...(featureScore && { featureScore }),
score,
values: processProtoValues(values),
token: t,
promotionPinned,
...(neuralScore && { neuralScore }),
...(featureScore && { featureScore }),
};
}
);
Expand All @@ -498,12 +498,12 @@ class QueryPipeline extends EventEmitter {
jsonProto.searchResponse?.totalResults || "0",
10
),
featureScoreWeight: jsonProto.searchResponse?.featureScoreWeight || 0,
results: results,
aggregates: aggregates,
aggregateFilters: aggregateFilters,
redirects: redirects,
activePromotions: activePromotions,
featureScoreWeight: jsonProto.searchResponse?.featureScoreWeight || 0,
},
jsonProto.values || {},
];
Expand All @@ -521,6 +521,11 @@ export interface SearchResponse {
*/
totalResults: number;

/**
* Feature score weight determines the weighting of featureScore vs neural and index scores.
*/
featureScoreWeight: number;

/**
* Results of the query.
*/
Expand All @@ -545,22 +550,13 @@ export interface SearchResponse {
* All Promotions activated by the current query (see [[ActivePromotion]]).
*/
activePromotions: ActivePromotion[];

/**
* Feature score weight determines the weighting of featureScore vs neural and index scores.
*/
featureScoreWeight: number;
}

export interface Result {
/**
* indexScore is the index-matched score of this [[Result]].
*/
indexScore: number;
/**
* score is the overall score of this [[Result]].
*/
score: number;
/**
* neuralScore is the neural score of this [[Result]].
*/
Expand All @@ -569,6 +565,10 @@ export interface Result {
* featureScore is the feature based search score of this [[Result]].
*/
featureScore?: number;
/**
* score is the overall score of this [[Result]].
*/
score: number;
/**
* values is an object of field-value pairs.
*/
Expand Down Expand Up @@ -666,10 +666,10 @@ export interface SearchResponseProto {
searchResponse?: Partial<{
time: string;
totalResults: string;
featureScoreWeight?: number;
results: ResultProto[];
aggregates: AggregatesProto;
aggregateFilters: AggregatesProto;
featureScoreWeight?: number;
}>;
tokens?: TokenProto[];
values?: Record<string, string>;
Expand Down
2 changes: 1 addition & 1 deletion src/user-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ if (scriptTag) {
* user agent of sdk
* @hidden
*/
export const USER_AGENT = ["sajari-sdk-js/2.8.1", suffix]
export const USER_AGENT = ["sajari-sdk-js/2.8.2", suffix]
.filter(Boolean)
.join(" ");

0 comments on commit 932a075

Please sign in to comment.