| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::ElasticSearch::Utilities::QueryString::Underscored; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: Extend some _<type>_ queries |
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
685
|
use strict; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
39
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
42
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '8.5'; # VERSION |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
7
|
use CLI::Helpers qw(:output); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
7
|
|
|
10
|
1
|
|
|
1
|
|
145
|
use namespace::autoclean; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
13
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
74
|
use Moo; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
18
|
|
|
13
|
|
|
|
|
|
|
with 'App::ElasticSearch::Utilities::QueryString::Plugin'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
36
|
sub _build_priority { 20; } |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my %Underscored = ( |
|
18
|
|
|
|
|
|
|
_prefix_ => sub { |
|
19
|
|
|
|
|
|
|
my ($v) = @_; |
|
20
|
|
|
|
|
|
|
my ($field,$text) = split /[:=]/, $v, 2; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
return unless defined $text and length $text; |
|
23
|
|
|
|
|
|
|
return { condition => { prefix => { $field => $text } } } |
|
24
|
|
|
|
|
|
|
}, |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub handle_token { |
|
29
|
|
|
|
|
|
|
my ($self,$token) = @_; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
debug(sprintf "%s - evaluating token '%s'", $self->name, $token); |
|
32
|
|
|
|
|
|
|
my ($k,$v) = split /:/, $token, 2; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
return unless exists $Underscored{lc $k} and defined $v; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
return $Underscored{lc $k}->($v); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Return True; |
|
40
|
|
|
|
|
|
|
1; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=pod |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 NAME |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
App::ElasticSearch::Utilities::QueryString::Underscored - Extend some _<type>_ queries |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 VERSION |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
version 8.5 |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 App::ElasticSearch::Utilities::QueryString::Underscored |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This plugin translates some special underscore surrounded tokens into |
|
59
|
|
|
|
|
|
|
the Elasticsearch Query DSL. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Implemented: |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head3 _prefix_ |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Example query string: |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
_prefix_:useragent:'Go ' |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Translates into: |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
{ prefix => { useragent => 'Go ' } } |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=for Pod::Coverage handle_token |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 AUTHOR |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Brad Lhotsky <brad@divisionbyzero.net> |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This software is Copyright (c) 2023 by Brad Lhotsky. |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This is free software, licensed under: |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
The (three-clause) BSD License |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |