src/core/domain/dtos/elastic/es-hit.dto.ts
Structure of the document stored and retrieved from Elasticsearch
Properties |
Optional _score |
Type : number
|
Decorators :
@IsOptional()
|
Hit relevance score |
_source |
Type : PaperDto
|
Decorators :
@IsNotEmpty()
|
Actual document stored in Elasticsearch |
import { ApiExtraModels, ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { IsNotEmpty, IsOptional } from "class-validator";
import { PaperDto } from "../paper.dto";
/**
* List of allowed properties in this DTO
*/
const allowedProperties = ['sort', '_source', '_score'];
/**
* Structure of the document stored and retrieved from Elasticsearch
*/
@ApiExtraModels()
export class EsHitDto {
/**
* Actual document stored in Elasticsearch
*/
@IsNotEmpty()
@ApiProperty({
description: 'Actual document (paper) stored in Elasticsearch',
example: {
id: 'sssss'
}
})
_source: PaperDto;
/**
* List of objects that represents how the hit was sorted
*/
@IsOptional()
@ApiPropertyOptional({
description: 'List of objects that represents how the hit was sorted',
example: {}
})
sort?: [];
/**
* Hit relevance score
*/
@IsOptional()
@ApiPropertyOptional({
description: 'Relevance score',
example: 1.2355
})
_score?: number;
}