scipaper/src/core/domain/dtos/es-hit.dto.ts
2022-08-16 19:22:27 +03:00

45 lines
1.0 KiB
TypeScript

import { ApiProperty } 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
*/
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()
@ApiProperty({
description: 'List of objects that represents how the hit was sorted',
example: {}
})
sort?: [];
/**
* Hit relevance score
*/
@IsOptional()
@ApiProperty({
description: 'Relevance score',
example: 1.2355
})
_score?: number;
}