-
Notifications
You must be signed in to change notification settings - Fork 1
/
elasticSearchQuery.model.ts
130 lines (109 loc) · 2.93 KB
/
elasticSearchQuery.model.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import { Field, Float, Int, ObjectType } from 'type-graphql';
@ObjectType()
class ESError {
@Field((type) => Int, { nullable: true, description: 'Error status code.' })
status?: string;
@Field((type) => String, {
description: 'Error message text message.'
})
reason!: string;
}
@ObjectType()
class SearchTotals {
@Field((type) => Int, {
description: 'Total number of hits matched to this particular request'
})
totalResults!: number;
@Field((type) => Int, {
description: 'Page offset, which has been used for this particular request.'
})
offset!: number;
@Field((type) => Int, {
description:
'Number of search hits per page, which has been used for this particular request.'
})
limit!: number;
@Field((type) => Float, {
description:
'Maximum score within results scope of this particular search request.'
})
maxScore!: number;
}
@ObjectType()
export class ElasticSearchQueryResultEntity {
@Field(() => [HitItem], {
nullable: 'items',
description: 'Search results list.'
})
hits!: HitItem[];
@Field((type) => SearchTotals, {
description: 'General information about particular search query result.'
})
total!: SearchTotals;
@Field((type) => ESError, {
nullable: true,
description: 'Occurred error.'
})
err?: ESError;
constructor(props: Partial<ElasticSearchQueryResultEntity>) {
Object.assign(this, props);
}
}
@ObjectType()
class HitItemContent {
@Field((type) => String, {
nullable: true,
description: 'Value of field `name` (actual only for Space entity)'
})
name?: string;
@Field((type) => String, {
nullable: true,
description: 'Value of field `about` (actual only for Space entity)'
})
about?: string;
@Field((type) => String, {
nullable: true,
description: 'Value of field `username` (actual only for Space entity)'
})
username?: string;
@Field((type) => String, {
nullable: true,
description: 'Value of field `title` (actual only for Post entity)'
})
title?: string;
@Field((type) => String, {
nullable: true,
description: 'Value of field `body` (actual only for Post entity)'
})
body?: string;
@Field((type) => String, {
nullable: true,
description: 'Value of field `spaceId` (actual only for Post entity)'
})
spaceId?: string;
@Field((type) => [String], { nullable: true, description: 'List of tags' })
tags?: string[];
}
@ObjectType()
class HitItem {
@Field((type) => String, {
nullable: false,
description: 'Index particular document is located in'
})
_index!: string;
@Field((type) => String, {
nullable: false,
description: 'Document ID (equal to on-chain entity ID)'
})
_id!: string;
@Field((type) => Float, {
nullable: false,
description: 'Search score of particular document'
})
_score!: number;
@Field((type) => HitItemContent, {
nullable: false,
description: 'Document source'
})
_content!: HitItemContent;
}