Created
July 24, 2023 08:50
-
-
Save DmitriyIudokhin/7bff9837d05d7944f5c837923157b384 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ElasticsearchService } from '@nestjs/elasticsearch'; | |
export class IngredientService { | |
constructor( | |
... | |
private readonly elasticsearchService: ElasticsearchService | |
... | |
) { | |
public async elastic_search(pBody: any, pUser: UserDocument) { | |
let aQueryParams = { | |
index: process.env.ELASTIC_SEARCH_OPTICS_INDEX, | |
body: JSON.stringify(pBody), | |
}; | |
let aResult = {}; | |
try { | |
aResult = await this.elasticsearchService.search(aQueryParams); | |
} catch (e) { | |
this.logger.error(`ElasticSearchService search failed: ${e}`); | |
throw new HttpException(`${e}`, HttpStatus.INTERNAL_SERVER_ERROR); | |
} | |
return aResult; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment