<<

NAME

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

SYNOPSIS

    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};
    }

DESCRIPTION

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.

METHODS

browse

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

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

count

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

fuzziness

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:

0..2

must match exactly

3..5

fuzziness edits allowed

>5

fuzziness+1 edits allowed

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

Returns

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.

_build_query

    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.

AUTHOR

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

<<