|
@@ -6,12 +6,14 @@ import {
|
|
|
CollectionService,
|
|
CollectionService,
|
|
|
ConfigService,
|
|
ConfigService,
|
|
|
DeepRequired,
|
|
DeepRequired,
|
|
|
|
|
+ EventBus,
|
|
|
FacetValue,
|
|
FacetValue,
|
|
|
FacetValueService,
|
|
FacetValueService,
|
|
|
InternalServerError,
|
|
InternalServerError,
|
|
|
Job,
|
|
Job,
|
|
|
Logger,
|
|
Logger,
|
|
|
RequestContext,
|
|
RequestContext,
|
|
|
|
|
+ SearchEvent,
|
|
|
SearchService,
|
|
SearchService,
|
|
|
} from '@vendure/core';
|
|
} from '@vendure/core';
|
|
|
import equal from 'fast-deep-equal/es6';
|
|
import equal from 'fast-deep-equal/es6';
|
|
@@ -46,6 +48,7 @@ export class ElasticsearchService implements OnModuleInit, OnModuleDestroy {
|
|
|
private configService: ConfigService,
|
|
private configService: ConfigService,
|
|
|
private facetValueService: FacetValueService,
|
|
private facetValueService: FacetValueService,
|
|
|
private collectionService: CollectionService,
|
|
private collectionService: CollectionService,
|
|
|
|
|
+ private eventBus: EventBus,
|
|
|
) {
|
|
) {
|
|
|
searchService.adopt(this);
|
|
searchService.adopt(this);
|
|
|
}
|
|
}
|
|
@@ -191,6 +194,7 @@ export class ElasticsearchService implements OnModuleInit, OnModuleDestroy {
|
|
|
body: elasticSearchBody,
|
|
body: elasticSearchBody,
|
|
|
});
|
|
});
|
|
|
const totalItems = await this.totalHits(ctx, input, groupByProduct);
|
|
const totalItems = await this.totalHits(ctx, input, groupByProduct);
|
|
|
|
|
+ this.eventBus.publish(new SearchEvent(ctx, input));
|
|
|
return {
|
|
return {
|
|
|
items: body.hits.hits.map(hit => this.mapProductToSearchResult(hit)),
|
|
items: body.hits.hits.map(hit => this.mapProductToSearchResult(hit)),
|
|
|
totalItems,
|
|
totalItems,
|
|
@@ -215,6 +219,7 @@ export class ElasticsearchService implements OnModuleInit, OnModuleDestroy {
|
|
|
index: indexPrefix + VARIANT_INDEX_NAME,
|
|
index: indexPrefix + VARIANT_INDEX_NAME,
|
|
|
body: elasticSearchBody,
|
|
body: elasticSearchBody,
|
|
|
});
|
|
});
|
|
|
|
|
+ this.eventBus.publish(new SearchEvent(ctx, input));
|
|
|
return {
|
|
return {
|
|
|
items: body.hits.hits.map(hit => this.mapVariantToSearchResult(hit)),
|
|
items: body.hits.hits.map(hit => this.mapVariantToSearchResult(hit)),
|
|
|
totalItems: body.hits.total ? body.hits.total.value : 0,
|
|
totalItems: body.hits.total ? body.hits.total.value : 0,
|