Koha::SearchEngine::ElasticSearch::Browse - browse functions for Elasticsearch


    my $browser =
      Koha::SearchEngine::Elasticsearch::Browse->new( { index => 'biblios' } );
    my $results = $browser->browse(
        'prefi', 'title',
            results   => '500',
            fuzziness => 2,
    foreach my $r (@$results) {
        push @hits, $r->{text};


This provides an easy interface to the "browse" functionality. Essentially, it does a fast prefix search on defined fields. The fields have to be marked as "suggestible" in the database when indexing takes place.



    my $results = $browser->browse($prefix, $field, \%options);

Does a prefix search for $prefix, looking in $field. Options are:


The number of results to return. For Koha browse purposes, this should probably be fairly high. Defaults to 500.


How much allowing for typos and misspellings is done. If 0, then it must match exactly. If unspecified, it defaults to '1', which is probably the most useful. Otherwise, it is a number specifying the Levenshtein edit distance relative to the string length, according to the following lengths:


must match exactly


fuzziness edits allowed


fuzziness+1 edits allowed

In all cases the maximum number of edits allowed is two (an elasticsearch restriction.)


This returns an arrayref of hashrefs. Each hashref contains a "text" element that contains the field as returned. There may be other fields in that hashref too, but they're less likely to be important.

The array will be ordered as returned from Elasticsearch, which seems to be in order of some form of relevance.


    my $query = $self->_build_query($prefix, $field, $options);

Arguments are the same as for browse. This will return a query structure for elasticsearch to use.


Robin Sheat << <robin@catalyst.net.nz> >>