line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Elastic::Model::TypeMap::ES; |
2
|
|
|
|
|
|
|
$Elastic::Model::TypeMap::ES::VERSION = '0.52'; |
3
|
23
|
|
|
23
|
|
17833
|
use strict; |
|
23
|
|
|
|
|
57
|
|
|
23
|
|
|
|
|
693
|
|
4
|
23
|
|
|
23
|
|
132
|
use warnings; |
|
23
|
|
|
|
|
47
|
|
|
23
|
|
|
|
|
711
|
|
5
|
|
|
|
|
|
|
|
6
|
23
|
|
|
23
|
|
132
|
use Elastic::Model::TypeMap::Base qw(:all); |
|
23
|
|
|
|
|
50
|
|
|
23
|
|
|
|
|
188
|
|
7
|
23
|
|
|
23
|
|
157
|
use namespace::autoclean; |
|
23
|
|
|
|
|
53
|
|
|
23
|
|
|
|
|
202
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has_type 'Elastic::Model::Types::UID', |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
deflate_via { |
13
|
|
|
|
|
|
|
'do {' |
14
|
|
|
|
|
|
|
. 'die "Cannot deflate UID as it not saved\n"' |
15
|
|
|
|
|
|
|
. 'unless $val->from_store;' |
16
|
|
|
|
|
|
|
. '$val->read_params;' . '}'; |
17
|
|
|
|
|
|
|
}, |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
inflate_via { |
20
|
|
|
|
|
|
|
'Elastic::Model::UID->new( from_store => 1, %$val )'; |
21
|
|
|
|
|
|
|
}, |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
map_via { |
24
|
|
|
|
|
|
|
my %props = map { $_ => { type => 'string', index => 'not_analyzed', } } |
25
|
|
|
|
|
|
|
qw(index type id routing); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$props{routing}{index} = 'no'; |
28
|
|
|
|
|
|
|
delete $props{routing}{index_name}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
return ( |
31
|
|
|
|
|
|
|
type => 'object', |
32
|
|
|
|
|
|
|
dynamic => 'strict', |
33
|
|
|
|
|
|
|
properties => \%props, |
34
|
|
|
|
|
|
|
path => 'full' |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has_type 'Elastic::Model::Types::Keyword', |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
map_via { |
43
|
|
|
|
|
|
|
type => 'string', |
44
|
|
|
|
|
|
|
index => 'not_analyzed' |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
has_type 'Elastic::Model::Types::GeoPoint', |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
deflate_via {'$val'}, |
51
|
|
|
|
|
|
|
inflate_via {'$val'}, |
52
|
|
|
|
|
|
|
map_via { type => 'geo_point' }; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
has_type 'Elastic::Model::Types::Binary', |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
deflate_via { |
58
|
|
|
|
|
|
|
require MIME::Base64; |
59
|
|
|
|
|
|
|
'MIME::Base64::encode_base64( $val )'; |
60
|
|
|
|
|
|
|
}, |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
inflate_via { |
63
|
|
|
|
|
|
|
'MIME::Base64::decode_base64( $val )'; |
64
|
|
|
|
|
|
|
}, |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
map_via { type => 'binary' }; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
has_type 'Elastic::Model::Types::Timestamp', |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
deflate_via {'int( $val * 1000 + 0.5 )'}, |
72
|
|
|
|
|
|
|
inflate_via {'sprintf "%.3f", $val / 1000'}, |
73
|
|
|
|
|
|
|
map_via { type => 'date' }; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=pod |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=encoding UTF-8 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 NAME |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Elastic::Model::TypeMap::ES - Type maps for ElasticSearch-specific types |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 VERSION |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
version 0.52 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 DESCRIPTION |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
L<Elastic::Model::TypeMap::ES> provides mapping, inflation and deflation |
96
|
|
|
|
|
|
|
for Elasticsearch specific types. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 TYPES |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 Elastic::Model::Types::Keyword |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Attributes of type L<Elastic::Model::Types/Keyword> are in/deflated |
103
|
|
|
|
|
|
|
via L<Elastic::Model::TypeMap::Moose/Any> and are mapped as: |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
{ |
106
|
|
|
|
|
|
|
type => 'string', |
107
|
|
|
|
|
|
|
index => 'not_analyzed' |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
It is a suitable type to use for string attributes which should not |
111
|
|
|
|
|
|
|
be analyzed, and will not be used for scoring. Rather they are suitable |
112
|
|
|
|
|
|
|
to use as filters. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 Elastic::Model::Types::UID |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
An L<Elastic::Model::UID> is deflated into a hash ref and reinflated |
117
|
|
|
|
|
|
|
via L<Elastic::Model::UID/"new_from_store()">. It is mapped as: |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
{ |
120
|
|
|
|
|
|
|
type => 'object', |
121
|
|
|
|
|
|
|
dynamic => 'strict', |
122
|
|
|
|
|
|
|
path => 'path', |
123
|
|
|
|
|
|
|
properties => { |
124
|
|
|
|
|
|
|
index => { |
125
|
|
|
|
|
|
|
type => 'string', |
126
|
|
|
|
|
|
|
index => 'not_analyzed' |
127
|
|
|
|
|
|
|
}, |
128
|
|
|
|
|
|
|
type => { |
129
|
|
|
|
|
|
|
type => 'string', |
130
|
|
|
|
|
|
|
index => 'not_analyzed' |
131
|
|
|
|
|
|
|
}, |
132
|
|
|
|
|
|
|
id => { |
133
|
|
|
|
|
|
|
type => 'string', |
134
|
|
|
|
|
|
|
index => 'not_analyzed' |
135
|
|
|
|
|
|
|
}, |
136
|
|
|
|
|
|
|
routing => { |
137
|
|
|
|
|
|
|
type => 'string', |
138
|
|
|
|
|
|
|
index => 'no' |
139
|
|
|
|
|
|
|
}, |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 Elastic::Model::Types::GeoPoint |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Attributes of type L<Elastic::Model::Types/"GeoPoint"> are mapped as |
146
|
|
|
|
|
|
|
C<< { type => 'geo_point' } >>. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 Elastic::Model::Types::Binary |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Attributes of type L<Elastic::Model::Types/"Binary"> are deflated via |
151
|
|
|
|
|
|
|
L<MIME::Base64/"encode_base64"> and inflated via L<MIME::Base64/"decode_base_64">. |
152
|
|
|
|
|
|
|
They are mapped as C<< { type => 'binary' } >>. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 Elastic::Model::Types::Timestamp |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Attributes of type L<Elastic::Model::Types/"Timestamp"> are deflated |
157
|
|
|
|
|
|
|
to epoch milliseconds, and inflated to epoch seconds (with floating-point |
158
|
|
|
|
|
|
|
milliseconds). It is mapped as C<< { type => 'date' } >>. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
B<Note:> When querying timestamp fields in a View you will need to express the |
161
|
|
|
|
|
|
|
comparison values as epoch milliseconds or as an RFC3339 datetime: |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
{ my_timestamp => { '>' => 1351748867 * 1000 }} |
164
|
|
|
|
|
|
|
{ my_timestamp => { '>' => '2012-11-01T00:00:00Z' }} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 AUTHOR |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Clinton Gormley <drtech@cpan.org> |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Clinton Gormley. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
175
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=cut |
178
|
|
|
|
|
|
|
|