Skip to content

Commit 1d6001a

Browse files
authored
Merge pull request #89 from Relewise/feat/highlighting-changes
feat: update with new settings for highligtning
2 parents 580cd82 + 740f0e6 commit 1d6001a

File tree

7 files changed

+81
-25
lines changed

7 files changed

+81
-25
lines changed

packages/client/src/builders/search/contentHighlightingBuilder.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ export class ContentHighlightingBuilder {
55
private highlightable: ContentHighlightProps = {
66
$type: 'Relewise.Client.Requests.Shared.Highlighting.ContentHighlightProps, Relewise.Client',
77
displayName: false
8-
};
8+
};
99
private limit: HighlightSettings2ContentContentHighlightPropsHighlightSettings2Limits = {};
1010
private shape: HighlightSettings2ContentContentHighlightPropsHighlightSettings2ResponseShape = {
1111
includeOffsets: false
1212
};
1313

1414
public enabled(enabled: boolean): this {
1515
this.enabledState = enabled;
16-
16+
1717
return this;
1818
}
1919

@@ -24,10 +24,8 @@ export class ContentHighlightingBuilder {
2424
return this;
2525
}
2626

27-
public setLimit(limit: { maxEntryLimit?: number | null; maxSnippetsPerEntry?: number | null; maxSnippetsPerField?: number | null; }): this {
28-
this.limit.maxEntryLimit = limit.maxEntryLimit;
29-
this.limit.maxSnippetsPerEntry = limit.maxSnippetsPerEntry;
30-
this.limit.maxSnippetsPerField = limit.maxSnippetsPerField;
27+
public setLimit(limit: HighlightSettings2ContentContentHighlightPropsHighlightSettings2Limits): this {
28+
this.limit = limit;
3129

3230
return this;
3331
}

packages/client/src/builders/search/productHighlightingBuilder.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ export class ProductHighlightingBuilder {
2424
return this;
2525
}
2626

27-
public setLimit(limit: { maxEntryLimit?: number | null; maxSnippetsPerEntry?: number | null; maxSnippetsPerField?: number | null; }): this {
28-
this.limit.maxEntryLimit = limit.maxEntryLimit;
29-
this.limit.maxSnippetsPerEntry = limit.maxSnippetsPerEntry;
30-
this.limit.maxSnippetsPerField = limit.maxSnippetsPerField;
27+
public setLimit(limit: HighlightSettings2ProductProductHighlightPropsHighlightSettings2Limits): this {
28+
this.limit = limit;
3129

3230
return this;
3331
}

packages/client/src/models/data-contracts.ts

Lines changed: 67 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export interface AbandonedCartTriggerResultTriggerConfiguration {
3838

3939
export type AbandonedSearchTriggerConfiguration = AbandonedSearchTriggerResultTriggerConfiguration & {
4040
searchTypesInPrioritizedOrder: ("Product" | "ProductCategory" | "Content")[];
41-
searchTermCondition?: SearchTermCondition | null;
41+
searchTermCondition?: SearchTermCondition | RetailMediaSearchTermCondition | null;
4242
suppressOnEntityFromSearchResultViewed: boolean;
4343
/** @format int32 */
4444
considerAbandonedAfterMinutes: number;
@@ -567,6 +567,7 @@ export type Campaign = CampaignEntityStateCampaignMetadataValuesRetailMediaEntit
567567
advertiserId: string;
568568
budget: CPMBudget;
569569
status: CampaignStatusWithHistory;
570+
conditions?: RetailMediaConditions | null;
570571
};
571572

572573
export interface CampaignAnalytics {
@@ -2122,9 +2123,11 @@ export interface FieldIndexConfiguration {
21222123
included: boolean;
21232124
/** @format int32 */
21242125
weight: number;
2126+
/** @deprecated */
21252127
predictionSourceType: "Disabled" | "IndividualWords" | "PartialWordSequences" | "CompleteWordSequence";
21262128
parser?: ClearTextParser | HtmlParser | null;
21272129
matchTypeSettings?: MatchTypeSettings | null;
2130+
predictionConfiguration?: PredictionConfiguration | null;
21282131
}
21292132

21302133
export interface Filter {
@@ -2365,6 +2368,14 @@ export interface HighlightSettings2ContentContentHighlightPropsHighlightSettings
23652368
maxSnippetsPerEntry?: number | null;
23662369
/** @format int32 */
23672370
maxSnippetsPerField?: number | null;
2371+
/** @format int32 */
2372+
maxWordsBeforeMatch?: number | null;
2373+
/** @format int32 */
2374+
maxWordsAfterMatch?: number | null;
2375+
/** @format int32 */
2376+
maxSentencesToIncludeBeforeMatch?: number | null;
2377+
/** @format int32 */
2378+
maxSentencesToIncludeAfterMatch?: number | null;
23682379
}
23692380

23702381
export interface HighlightSettings2ContentContentHighlightPropsHighlightSettings2ResponseShape {
@@ -2374,6 +2385,7 @@ export interface HighlightSettings2ContentContentHighlightPropsHighlightSettings
23742385

23752386
export interface HighlightSettings2ContentContentHighlightPropsHighlightSettings2TextSnippetsSettings {
23762387
includeTextSnippets: boolean;
2388+
includeEllipses: boolean;
23772389
}
23782390

23792391
export interface HighlightSettings2ProductProductHighlightPropsHighlightSettings2Limits {
@@ -2383,6 +2395,14 @@ export interface HighlightSettings2ProductProductHighlightPropsHighlightSettings
23832395
maxSnippetsPerEntry?: number | null;
23842396
/** @format int32 */
23852397
maxSnippetsPerField?: number | null;
2398+
/** @format int32 */
2399+
maxWordsBeforeMatch?: number | null;
2400+
/** @format int32 */
2401+
maxWordsAfterMatch?: number | null;
2402+
/** @format int32 */
2403+
maxSentencesToIncludeBeforeMatch?: number | null;
2404+
/** @format int32 */
2405+
maxSentencesToIncludeAfterMatch?: number | null;
23862406
}
23872407

23882408
export interface HighlightSettings2ProductProductHighlightPropsHighlightSettings2ResponseShape {
@@ -2392,6 +2412,7 @@ export interface HighlightSettings2ProductProductHighlightPropsHighlightSettings
23922412

23932413
export interface HighlightSettings2ProductProductHighlightPropsHighlightSettings2TextSnippetsSettings {
23942414
includeTextSnippets: boolean;
2415+
includeEllipses: boolean;
23952416
}
23962417

23972418
export type HtmlParser = Parser;
@@ -3034,10 +3055,14 @@ export interface PopularityMultiplierSelector {
30343055
$type: string;
30353056
}
30363057

3058+
export interface PredictionConfiguration {
3059+
includeInPredictions: boolean;
3060+
}
3061+
30373062
export type PredictionRule = SearchRule & {
3038-
condition: SearchTermCondition;
3039-
promote: PredictionRulePromotion;
3040-
suppress: PredictionRuleSuppression;
3063+
condition: SearchTermCondition | RetailMediaSearchTermCondition;
3064+
promote?: PredictionRulePromotion | null;
3065+
suppress?: PredictionRuleSuppression | null;
30413066
};
30423067

30433068
export interface PredictionRulePromotion {
@@ -3917,6 +3942,7 @@ export interface ProductProductHighlightPropsHighlightSettings {
39173942

39183943
export type ProductPromotion = Promotion & {
39193944
filters?: FilterCollection | null;
3945+
conditions?: RetailMediaConditions | null;
39203946
};
39213947

39223948
export type ProductPromotionSpecification = PromotionSpecification & {
@@ -4398,6 +4424,27 @@ export type PurchasedWithProductRequest = ProductRecommendationRequest & {
43984424
productAndVariantId: ProductAndVariantId;
43994425
};
44004426

4427+
export interface RebuildStatus {
4428+
isRebuilding: boolean;
4429+
isStale: boolean;
4430+
/** @format date-time */
4431+
lastRebuildStarted: string;
4432+
/** @format date-time */
4433+
lastRebuildCompleted: string;
4434+
/** @format date-time */
4435+
lastRebuildOpportunity: string;
4436+
/** @format date-span */
4437+
lastRebuildDuration: string;
4438+
isBuilt: boolean;
4439+
isPartial: boolean;
4440+
/** @format date-time */
4441+
lastMarkedAsStale: string;
4442+
/** @format date-span */
4443+
staleDuration: string;
4444+
/** @format date-span */
4445+
lastStaleDuration: string;
4446+
}
4447+
44014448
export type RecentlyPurchasedFacet = BooleanValueFacet & {
44024449
purchaseQualifiers: PurchaseQualifiers;
44034450
};
@@ -4460,13 +4507,13 @@ export interface RecommendationTypeCollection {
44604507
export interface RedirectResult {
44614508
/** @format uuid */
44624509
id: string;
4463-
condition: SearchTermCondition;
4510+
condition: SearchTermCondition | RetailMediaSearchTermCondition;
44644511
destination?: string | null;
44654512
data?: Record<string, string>;
44664513
}
44674514

44684515
export type RedirectRule = SearchRule & {
4469-
condition: SearchTermCondition;
4516+
condition: SearchTermCondition | RetailMediaSearchTermCondition;
44704517
destination?: string | null;
44714518
data?: Record<string, string>;
44724519
};
@@ -4585,6 +4632,10 @@ export type ResultMustHaveVariantConstraint = ProductSearchResultConstraint & {
45854632
exceptWhenProductHasNoVariants: boolean;
45864633
};
45874634

4635+
export interface RetailMediaConditions {
4636+
searchTerm?: RetailMediaSearchTermCondition | null;
4637+
}
4638+
45884639
export interface RetailMediaEntity2AdvertiserEntityStateAdvertiserMetadataValuesRetailMediaEntity2EntityFilters {
45894640
$type: string;
45904641
term?: string | null;
@@ -4637,6 +4688,8 @@ export interface RetailMediaResultPlacementResultEntityProduct {
46374688
result: ProductResult;
46384689
}
46394690

4691+
export type RetailMediaSearchTermCondition = SearchTermCondition;
4692+
46404693
export type SaveAdvertisersRequest = AdvertiserSaveEntitiesRequest;
46414694

46424695
export type SaveAdvertisersResponse = AdvertiserSaveEntitiesResponse;
@@ -4724,6 +4777,7 @@ export interface SearchIndex {
47244777
modifiedBy?: string | null;
47254778
custom?: Record<string, string | null>;
47264779
configuration?: IndexConfiguration | null;
4780+
rebuildStatus?: RebuildStatus | null;
47274781
}
47284782

47294783
export type SearchIndexCollectionResponse = TimedResponse & {
@@ -4789,7 +4843,7 @@ export type SearchResponseCollection = SearchResponse & {
47894843
};
47904844

47914845
export type SearchResultModifierRule = SearchRule & {
4792-
condition: SearchTermCondition;
4846+
condition: SearchTermCondition | RetailMediaSearchTermCondition;
47934847
actions: (SearchResultModifierRuleAddFiltersAction | SearchResultModifierRuleAddTermFilterAction)[];
47944848
};
47954849

@@ -4889,16 +4943,18 @@ export type SearchTermBasedProductRecommendationRequest = ProductRecommendationR
48894943
};
48904944

48914945
export interface SearchTermCondition {
4946+
$type: string;
48924947
kind?: "Equals" | "StartsWith" | "EndsWith" | "Contains" | null;
48934948
value?: string | null;
4894-
andConditions?: SearchTermCondition[] | null;
4895-
orConditions?: SearchTermCondition[] | null;
4949+
andConditions?: (SearchTermCondition | RetailMediaSearchTermCondition)[] | null;
4950+
orConditions?: (SearchTermCondition | RetailMediaSearchTermCondition)[] | null;
48964951
/** @format int32 */
48974952
minimumLength?: number | null;
4953+
negated: boolean;
48984954
}
48994955

49004956
export type SearchTermModifierRule = SearchRule & {
4901-
condition: SearchTermCondition;
4957+
condition: SearchTermCondition | RetailMediaSearchTermCondition;
49024958
actions: (
49034959
| SearchTermModifierRuleAppendToTermAction
49044960
| SearchTermModifierRuleRemoveFromTermAction
@@ -4985,6 +5041,7 @@ export interface SearchTermPredictionResult {
49855041
/** @format int32 */
49865042
rank: number;
49875043
expectedResultTypes?: ExpectedSearchTermResult[] | null;
5044+
/** @deprecated */
49885045
type: "Match" | "WordContinuation" | "Word" | "WordSequence";
49895046
correctedWordsMask?: boolean[] | null;
49905047
}

packages/client/tests/integration-tests/contentSearch.integration.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ test('Highlighting', async() => {
4242
.setTerm('highlighted')
4343
.highlighting(h => {
4444
h.setHighlightable({ dataKeys: ['Description'] })
45+
h.setLimit({ maxWordsBeforeMatch: 3 })
4546
// You have to specify to include the offset.
4647
// Currently offset is the only way to get a result, so if not set, you won't get a result.
47-
h.setShape({ includeOffsets: true, textSnippets: { includeTextSnippets: true } })
48+
h.setShape({ includeOffsets: true, textSnippets: { includeTextSnippets: true, includeEllipses: true } })
4849
}).build();
4950

5051
const result = await searcher.searchContents(request);

packages/client/tests/integration-tests/productSearch.integration.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ test('ProductSearch with search constraint', async() => {
9797

9898
test('Highlighting', async() => {
9999
const request: ProductSearchRequest = baseProductBuilder()
100-
.setTerm('highlighted')
100+
.setTerm('SomeValue')
101101
.highlighting(h => {
102-
h.setHighlightable({ dataKeys: ['Description'] })
102+
h.setHighlightable({ dataKeys: ['SomeString'] })
103103
// You have to specify to include the offset.
104104
// Currently offset is the only way to get a result, so if not set, you won't get a result.
105-
h.setShape({ includeOffsets: true, textSnippets: { includeTextSnippets: true } })
105+
h.setShape({ includeOffsets: true, textSnippets: { includeTextSnippets: true, includeEllipses: true } })
106106
}).build();
107107
const result = await searcher.searchProducts(request);
108108

109109
expect(result?.results![0].highlight?.offsets?.data[0].value.length).toBeGreaterThan(0);
110-
expect(result?.results![0].highlight?.snippets?.data[0].value[0]).toBe("...last word is highlighted");
110+
expect(result?.results![0].highlight?.snippets?.data[0].value[0]).toBe("SomeValue");
111111
})

packages/client/tests/unit-tests/builders/search/contentSearchBuilder.unit.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ test('searchHightlighting', () => {
2828
h.setShape({
2929
includeOffsets: true,
3030
textSnippets: {
31+
includeEllipses: true,
3132
includeTextSnippets: true
3233
}
3334
});

packages/client/tests/unit-tests/builders/search/productSearchBuilder.unit.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ test('searchHightlighting', () => {
122122
h.setShape({
123123
includeOffsets: true,
124124
textSnippets: {
125+
includeEllipses: true,
125126
includeTextSnippets: true,
126127
}
127128
});

0 commit comments

Comments
 (0)