Solstice::SearchField - Represents one field a model defines in the search index.


Solstice documentation Contained in the Solstice distribution.

Index


Code Index:

NAME

Top

Solstice::SearchField - Represents one field a model defines in the search index.

SYNOPSIS

Top

#within a model's store method, for example:

my $content_field = $self->createSearchField('content', $self->getContent());

$content_field->setStored(0); $content_field->setCompressed(1);

DESCRIPTION

Top

This allows for the creation of a searched bit of content. The bit of content can then have various options set about it's behavior in the index.

new
getName
getContent
getOptions

Retuns a hash of the options you have set - this is for backend use mostly.

setWeight

Set the relevance multiplier for matches in this field

setIndexed

Do we search it or just store it with the record?

setAnalyzed

Is the field stemmed/stopworded/etc

setStored

Is the field stored or just indexed

setCompressed

Should the stored content be gzipped

setVectorized

Should vector data be generated and stored, so matches can be highlighted in excerpts while searching

COPYRIGHT

Top


Solstice documentation Contained in the Solstice distribution.
package Solstice::SearchField;

# $Id:$


use strict;
use warnings;
use 5.006_000;

use base qw(Solstice);

sub new {
    my $pkg = shift;
    my $name = shift;
    my $content = shift;
    my $self = $pkg->SUPER::new();

    return unless $name;
    $content = '' unless $content;

    $self->{'options'} = {};
    $self->{'options'}{'name'} = $name;
    $self->{'content'} = $content;

    return $self;
}

sub getName {
    my $self = shift;
    return $self->{'options'}{'name'};
}

sub getContent {
    my $self = shift;
    return $self->{'content'};
}

sub getOptions {
    my $self = shift;
    return %{$self->{'options'}};
}

sub setWeight {
    my $self = shift;
    my $weight = shift;

    die "Non positive multiplier passed to Solstice::SearchField::setWeight from ".join(' ', caller) unless $self->isValidPositiveNumber($weight);

    $self->{'boost'} = $weight;
}

sub setIndexed {
    my $self = shift;
    $self->{'options'}{'indexed'} = shift;
}

sub setAnalyzed {
    my $self = shift;
    $self->{'options'}{'analyzed'} = shift;
}

sub setStored {
    my $self = shift;
    $self->{'options'}{'stored'} = shift;
}

sub setCompressed {
    my $self = shift;
    $self->{'options'}{'compressed'} = shift;
}

sub setVectorized {
    my $self = shift;
    $self->{'options'}{'vectorized'} = shift;
}


1;