diff --git a/packages/client/src/builders/search/contentHighlightingBuilder.ts b/packages/client/src/builders/search/contentHighlightingBuilder.ts index 96ff356..0af95ae 100644 --- a/packages/client/src/builders/search/contentHighlightingBuilder.ts +++ b/packages/client/src/builders/search/contentHighlightingBuilder.ts @@ -5,7 +5,7 @@ export class ContentHighlightingBuilder { private highlightable: ContentHighlightProps = { $type: 'Relewise.Client.Requests.Shared.Highlighting.ContentHighlightProps, Relewise.Client', displayName: false - }; + }; private limit: HighlightSettings2ContentContentHighlightPropsHighlightSettings2Limits = {}; private shape: HighlightSettings2ContentContentHighlightPropsHighlightSettings2ResponseShape = { includeOffsets: false @@ -13,7 +13,7 @@ export class ContentHighlightingBuilder { public enabled(enabled: boolean): this { this.enabledState = enabled; - + return this; } @@ -24,10 +24,8 @@ export class ContentHighlightingBuilder { return this; } - public setLimit(limit: { maxEntryLimit?: number | null; maxSnippetsPerEntry?: number | null; maxSnippetsPerField?: number | null; }): this { - this.limit.maxEntryLimit = limit.maxEntryLimit; - this.limit.maxSnippetsPerEntry = limit.maxSnippetsPerEntry; - this.limit.maxSnippetsPerField = limit.maxSnippetsPerField; + public setLimit(limit: HighlightSettings2ContentContentHighlightPropsHighlightSettings2Limits): this { + this.limit = limit; return this; } diff --git a/packages/client/src/builders/search/productHighlightingBuilder.ts b/packages/client/src/builders/search/productHighlightingBuilder.ts index 5e2d6ab..3d017cb 100644 --- a/packages/client/src/builders/search/productHighlightingBuilder.ts +++ b/packages/client/src/builders/search/productHighlightingBuilder.ts @@ -24,10 +24,8 @@ export class ProductHighlightingBuilder { return this; } - public setLimit(limit: { maxEntryLimit?: number | null; maxSnippetsPerEntry?: number | null; maxSnippetsPerField?: number | null; }): this { - this.limit.maxEntryLimit = limit.maxEntryLimit; - this.limit.maxSnippetsPerEntry = limit.maxSnippetsPerEntry; - this.limit.maxSnippetsPerField = limit.maxSnippetsPerField; + public setLimit(limit: HighlightSettings2ProductProductHighlightPropsHighlightSettings2Limits): this { + this.limit = limit; return this; } diff --git a/packages/client/src/models/data-contracts.ts b/packages/client/src/models/data-contracts.ts index 0e9bc19..8dafd3f 100644 --- a/packages/client/src/models/data-contracts.ts +++ b/packages/client/src/models/data-contracts.ts @@ -38,7 +38,7 @@ export interface AbandonedCartTriggerResultTriggerConfiguration { export type AbandonedSearchTriggerConfiguration = AbandonedSearchTriggerResultTriggerConfiguration & { searchTypesInPrioritizedOrder: ("Product" | "ProductCategory" | "Content")[]; - searchTermCondition?: SearchTermCondition | null; + searchTermCondition?: SearchTermCondition | RetailMediaSearchTermCondition | null; suppressOnEntityFromSearchResultViewed: boolean; /** @format int32 */ considerAbandonedAfterMinutes: number; @@ -567,6 +567,7 @@ export type Campaign = CampaignEntityStateCampaignMetadataValuesRetailMediaEntit advertiserId: string; budget: CPMBudget; status: CampaignStatusWithHistory; + conditions?: RetailMediaConditions | null; }; export interface CampaignAnalytics { @@ -2122,9 +2123,11 @@ export interface FieldIndexConfiguration { included: boolean; /** @format int32 */ weight: number; + /** @deprecated */ predictionSourceType: "Disabled" | "IndividualWords" | "PartialWordSequences" | "CompleteWordSequence"; parser?: ClearTextParser | HtmlParser | null; matchTypeSettings?: MatchTypeSettings | null; + predictionConfiguration?: PredictionConfiguration | null; } export interface Filter { @@ -2365,6 +2368,14 @@ export interface HighlightSettings2ContentContentHighlightPropsHighlightSettings maxSnippetsPerEntry?: number | null; /** @format int32 */ maxSnippetsPerField?: number | null; + /** @format int32 */ + maxWordsBeforeMatch?: number | null; + /** @format int32 */ + maxWordsAfterMatch?: number | null; + /** @format int32 */ + maxSentencesToIncludeBeforeMatch?: number | null; + /** @format int32 */ + maxSentencesToIncludeAfterMatch?: number | null; } export interface HighlightSettings2ContentContentHighlightPropsHighlightSettings2ResponseShape { @@ -2374,6 +2385,7 @@ export interface HighlightSettings2ContentContentHighlightPropsHighlightSettings export interface HighlightSettings2ContentContentHighlightPropsHighlightSettings2TextSnippetsSettings { includeTextSnippets: boolean; + includeEllipses: boolean; } export interface HighlightSettings2ProductProductHighlightPropsHighlightSettings2Limits { @@ -2383,6 +2395,14 @@ export interface HighlightSettings2ProductProductHighlightPropsHighlightSettings maxSnippetsPerEntry?: number | null; /** @format int32 */ maxSnippetsPerField?: number | null; + /** @format int32 */ + maxWordsBeforeMatch?: number | null; + /** @format int32 */ + maxWordsAfterMatch?: number | null; + /** @format int32 */ + maxSentencesToIncludeBeforeMatch?: number | null; + /** @format int32 */ + maxSentencesToIncludeAfterMatch?: number | null; } export interface HighlightSettings2ProductProductHighlightPropsHighlightSettings2ResponseShape { @@ -2392,6 +2412,7 @@ export interface HighlightSettings2ProductProductHighlightPropsHighlightSettings export interface HighlightSettings2ProductProductHighlightPropsHighlightSettings2TextSnippetsSettings { includeTextSnippets: boolean; + includeEllipses: boolean; } export type HtmlParser = Parser; @@ -3034,10 +3055,14 @@ export interface PopularityMultiplierSelector { $type: string; } +export interface PredictionConfiguration { + includeInPredictions: boolean; +} + export type PredictionRule = SearchRule & { - condition: SearchTermCondition; - promote: PredictionRulePromotion; - suppress: PredictionRuleSuppression; + condition: SearchTermCondition | RetailMediaSearchTermCondition; + promote?: PredictionRulePromotion | null; + suppress?: PredictionRuleSuppression | null; }; export interface PredictionRulePromotion { @@ -3917,6 +3942,7 @@ export interface ProductProductHighlightPropsHighlightSettings { export type ProductPromotion = Promotion & { filters?: FilterCollection | null; + conditions?: RetailMediaConditions | null; }; export type ProductPromotionSpecification = PromotionSpecification & { @@ -4398,6 +4424,27 @@ export type PurchasedWithProductRequest = ProductRecommendationRequest & { productAndVariantId: ProductAndVariantId; }; +export interface RebuildStatus { + isRebuilding: boolean; + isStale: boolean; + /** @format date-time */ + lastRebuildStarted: string; + /** @format date-time */ + lastRebuildCompleted: string; + /** @format date-time */ + lastRebuildOpportunity: string; + /** @format date-span */ + lastRebuildDuration: string; + isBuilt: boolean; + isPartial: boolean; + /** @format date-time */ + lastMarkedAsStale: string; + /** @format date-span */ + staleDuration: string; + /** @format date-span */ + lastStaleDuration: string; +} + export type RecentlyPurchasedFacet = BooleanValueFacet & { purchaseQualifiers: PurchaseQualifiers; }; @@ -4460,13 +4507,13 @@ export interface RecommendationTypeCollection { export interface RedirectResult { /** @format uuid */ id: string; - condition: SearchTermCondition; + condition: SearchTermCondition | RetailMediaSearchTermCondition; destination?: string | null; data?: Record; } export type RedirectRule = SearchRule & { - condition: SearchTermCondition; + condition: SearchTermCondition | RetailMediaSearchTermCondition; destination?: string | null; data?: Record; }; @@ -4585,6 +4632,10 @@ export type ResultMustHaveVariantConstraint = ProductSearchResultConstraint & { exceptWhenProductHasNoVariants: boolean; }; +export interface RetailMediaConditions { + searchTerm?: RetailMediaSearchTermCondition | null; +} + export interface RetailMediaEntity2AdvertiserEntityStateAdvertiserMetadataValuesRetailMediaEntity2EntityFilters { $type: string; term?: string | null; @@ -4637,6 +4688,8 @@ export interface RetailMediaResultPlacementResultEntityProduct { result: ProductResult; } +export type RetailMediaSearchTermCondition = SearchTermCondition; + export type SaveAdvertisersRequest = AdvertiserSaveEntitiesRequest; export type SaveAdvertisersResponse = AdvertiserSaveEntitiesResponse; @@ -4724,6 +4777,7 @@ export interface SearchIndex { modifiedBy?: string | null; custom?: Record; configuration?: IndexConfiguration | null; + rebuildStatus?: RebuildStatus | null; } export type SearchIndexCollectionResponse = TimedResponse & { @@ -4789,7 +4843,7 @@ export type SearchResponseCollection = SearchResponse & { }; export type SearchResultModifierRule = SearchRule & { - condition: SearchTermCondition; + condition: SearchTermCondition | RetailMediaSearchTermCondition; actions: (SearchResultModifierRuleAddFiltersAction | SearchResultModifierRuleAddTermFilterAction)[]; }; @@ -4889,16 +4943,18 @@ export type SearchTermBasedProductRecommendationRequest = ProductRecommendationR }; export interface SearchTermCondition { + $type: string; kind?: "Equals" | "StartsWith" | "EndsWith" | "Contains" | null; value?: string | null; - andConditions?: SearchTermCondition[] | null; - orConditions?: SearchTermCondition[] | null; + andConditions?: (SearchTermCondition | RetailMediaSearchTermCondition)[] | null; + orConditions?: (SearchTermCondition | RetailMediaSearchTermCondition)[] | null; /** @format int32 */ minimumLength?: number | null; + negated: boolean; } export type SearchTermModifierRule = SearchRule & { - condition: SearchTermCondition; + condition: SearchTermCondition | RetailMediaSearchTermCondition; actions: ( | SearchTermModifierRuleAppendToTermAction | SearchTermModifierRuleRemoveFromTermAction @@ -4985,6 +5041,7 @@ export interface SearchTermPredictionResult { /** @format int32 */ rank: number; expectedResultTypes?: ExpectedSearchTermResult[] | null; + /** @deprecated */ type: "Match" | "WordContinuation" | "Word" | "WordSequence"; correctedWordsMask?: boolean[] | null; } diff --git a/packages/client/tests/integration-tests/contentSearch.integration.test.ts b/packages/client/tests/integration-tests/contentSearch.integration.test.ts index 9f8a2c7..0cfcc3a 100644 --- a/packages/client/tests/integration-tests/contentSearch.integration.test.ts +++ b/packages/client/tests/integration-tests/contentSearch.integration.test.ts @@ -42,9 +42,10 @@ test('Highlighting', async() => { .setTerm('highlighted') .highlighting(h => { h.setHighlightable({ dataKeys: ['Description'] }) + h.setLimit({ maxWordsBeforeMatch: 3 }) // You have to specify to include the offset. // Currently offset is the only way to get a result, so if not set, you won't get a result. - h.setShape({ includeOffsets: true, textSnippets: { includeTextSnippets: true } }) + h.setShape({ includeOffsets: true, textSnippets: { includeTextSnippets: true, includeEllipses: true } }) }).build(); const result = await searcher.searchContents(request); diff --git a/packages/client/tests/integration-tests/productSearch.integration.test.ts b/packages/client/tests/integration-tests/productSearch.integration.test.ts index 5c33bdd..c2ce34c 100644 --- a/packages/client/tests/integration-tests/productSearch.integration.test.ts +++ b/packages/client/tests/integration-tests/productSearch.integration.test.ts @@ -97,15 +97,15 @@ test('ProductSearch with search constraint', async() => { test('Highlighting', async() => { const request: ProductSearchRequest = baseProductBuilder() - .setTerm('highlighted') + .setTerm('SomeValue') .highlighting(h => { - h.setHighlightable({ dataKeys: ['Description'] }) + h.setHighlightable({ dataKeys: ['SomeString'] }) // You have to specify to include the offset. // Currently offset is the only way to get a result, so if not set, you won't get a result. - h.setShape({ includeOffsets: true, textSnippets: { includeTextSnippets: true } }) + h.setShape({ includeOffsets: true, textSnippets: { includeTextSnippets: true, includeEllipses: true } }) }).build(); const result = await searcher.searchProducts(request); expect(result?.results![0].highlight?.offsets?.data[0].value.length).toBeGreaterThan(0); - expect(result?.results![0].highlight?.snippets?.data[0].value[0]).toBe("...last word is highlighted"); + expect(result?.results![0].highlight?.snippets?.data[0].value[0]).toBe("SomeValue"); }) diff --git a/packages/client/tests/unit-tests/builders/search/contentSearchBuilder.unit.test.ts b/packages/client/tests/unit-tests/builders/search/contentSearchBuilder.unit.test.ts index 4bfbc36..baca30a 100644 --- a/packages/client/tests/unit-tests/builders/search/contentSearchBuilder.unit.test.ts +++ b/packages/client/tests/unit-tests/builders/search/contentSearchBuilder.unit.test.ts @@ -28,6 +28,7 @@ test('searchHightlighting', () => { h.setShape({ includeOffsets: true, textSnippets: { + includeEllipses: true, includeTextSnippets: true } }); diff --git a/packages/client/tests/unit-tests/builders/search/productSearchBuilder.unit.test.ts b/packages/client/tests/unit-tests/builders/search/productSearchBuilder.unit.test.ts index 40f7a9e..ae8fd93 100644 --- a/packages/client/tests/unit-tests/builders/search/productSearchBuilder.unit.test.ts +++ b/packages/client/tests/unit-tests/builders/search/productSearchBuilder.unit.test.ts @@ -122,6 +122,7 @@ test('searchHightlighting', () => { h.setShape({ includeOffsets: true, textSnippets: { + includeEllipses: true, includeTextSnippets: true, } });