NAME

KinoSearch::Docs::Tutorial::FieldSpec - Specify per-field properties and behaviors.

DESCRIPTION

The Schema subclass we used in the last chapter specifies three fields:

    our %fields = (
        title   => 'text',
        content => 'text',
        url     => 'text',
    );

Since they are all defined as "text" fields, they are all searchable -- including the url field, a dubious choice. Some URLs contain meaningful information, but these don't, really:

    http://example.com/us_constitution/amend1.html

We may as well not bother indexing the URL content. To achieve that we need to assign the url field to a custom subclass of KinoSearch::FieldSpec::TextField.

    package USConSchema::NotIndexed;
    use base qw( KinoSearch::FieldSpec::TextField );
    sub indexed { 0 }

    package USConSchema;
    use base qw( KinoSearch::Schema );

    our %fields = (
        title   => 'text',
        content => 'text',
        url     => 'USConSchema::NotIndexed',
    );

To observe the change in behavior, try searching for us_constitution both before and after changing the Schema and re-indexing.

Toggling stored()

For a taste of other FieldSpec possibilities, try turning off stored() for one or more fields.

    package USConSchema::NotStored;
    use base qw( KinoSearch::FieldSpec::TextField );
    sub stored { 0 }

Turning it off stored() for either title or url mangles our results page, but since we're not displaying content, turning it off for content has no effect -- except on index size.

COPYRIGHT

Copyright 2008 Marvin Humphrey

LICENSE, DISCLAIMER, BUGS, etc.

See KinoSearch version 0.20.

Copyright © 2004-2008 Marvin Humphrey