View | Details | Raw Unified | Return to bug 20596
Collapse All | Expand All

(-)a/C4/AuthoritiesMarc.pm (-2 / +17 lines)
Lines 207-215 sub SearchAuthorities { Link Here
207
    }
207
    }
208
    ##Add how many queries generated
208
    ##Add how many queries generated
209
    if (defined $query && $query=~/\S+/){
209
    if (defined $query && $query=~/\S+/){
210
        #NOTE: This code path is used by authority search in cataloguing plugins...
211
        #FIXME: This does not quite work the way the author probably intended.
212
        #It creates a ($query prefix) AND (query 1) AND (query 2) structure instead of
213
        #($query prefix) AND (query 1 AND query 2)
210
      $query= $and x $attr_cnt . $query . (defined $q2 ? $q2 : '');
214
      $query= $and x $attr_cnt . $query . (defined $q2 ? $q2 : '');
211
    } else {
215
    } else {
212
      $query= $q2;
216
        #NOTE: This code path is used by authority search in authority home and record matching rules...
217
        my $op_prefix = '';
218
        #NOTE: Without the following code, multiple queries will never be joined together
219
        #with a Boolean operator.
220
        if ($attr_cnt > 1){
221
            #NOTE: We always need 1 less operator than we have operands,
222
            #so long as there is more than 1 operand
223
            my $or_cnt = $attr_cnt - 1;
224
            #NOTE: We hard-code OR here because that's what Elasticsearch does
225
            $op_prefix = ' @or ' x $or_cnt;
226
            #NOTE: This evaluates to a logical structure like (query 1) OR (query 2) OR (query 3)
227
        }
228
      $query= $op_prefix . $q2;
213
    }
229
    }
214
    ## Adding order
230
    ## Adding order
215
    #$query=' @or  @attr 7=2 @attr 1=Heading 0 @or  @attr 7=1 @attr 1=Heading 1'.$query if ($sortby eq "HeadingDsc");
231
    #$query=' @or  @attr 7=2 @attr 1=Heading 0 @or  @attr 7=1 @attr 1=Heading 1'.$query if ($sortby eq "HeadingDsc");
216
- 

Return to bug 20596