Bug 12478 - more authority query building
Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
This commit is contained in:
parent
05fa9bccb0
commit
8c85389558
1 changed files with 11 additions and 2 deletions
|
@ -269,7 +269,7 @@ sub build_authorities_query {
|
||||||
if ($op eq 'is' || $op eq '=') {
|
if ($op eq 'is' || $op eq '=') {
|
||||||
# look for something that matches completely
|
# look for something that matches completely
|
||||||
# note, '=' is about numerical vals. May need special handling.
|
# note, '=' is about numerical vals. May need special handling.
|
||||||
push @filter_parts, { filter => { term => { $wh => $val }} };
|
push @filter_parts, { term => { $wh => $val }};
|
||||||
} elsif ($op eq 'exact') {
|
} elsif ($op eq 'exact') {
|
||||||
# left and right truncation, otherwise an exact phrase
|
# left and right truncation, otherwise an exact phrase
|
||||||
push @query_parts, { match_phrase => { $wh => $val }};
|
push @query_parts, { match_phrase => { $wh => $val }};
|
||||||
|
@ -280,7 +280,16 @@ sub build_authorities_query {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# Merge the query and filter parts appropriately
|
# Merge the query and filter parts appropriately
|
||||||
|
# 'should' behaves like 'or', if we want 'and', use 'must'
|
||||||
|
my $query_part = { bool => { should => \@query_parts } };
|
||||||
|
my $filter_part = { bool => { should => \@filter_parts }};
|
||||||
|
my $query;
|
||||||
|
if (@filter_parts) {
|
||||||
|
$query = { query => { filtered => { filter => $filter_part, query => $query_part }}};
|
||||||
|
} else {
|
||||||
|
$query = { query => $query_part };
|
||||||
|
}
|
||||||
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue