24 Dec 2009 00:10:44 UTC
- Development release
- Distribution: KinoSearch
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (5)
- Testers (68 / 0 / 15)
- KwaliteeBus factor: 0
- License: perl_5
- Activity24 month
- Download (809.92KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionCREAMYG Marvin Humphreyand 1 contributors
- Marvin Humphrey <marvin at rectangular dot com>
- LICENSE, DISCLAIMER, BUGS, etc.
KinoSearch::Docs::Tutorial::FieldType - Specify per-field properties and behaviors.
The Schema we used in the last chapter specifies three fields:
my $type = KinoSearch::FieldType::FullTextType->new( analyzer => $polyanalyzer, ); $schema->spec_field( name => 'title', type => $type ); $schema->spec_field( name => 'content', type => $type ); $schema->spec_field( name => 'url', type => $type );
Since they are all defined as "full text" fields, they are all searchable -- including the
urlfield, a dubious choice. Some URLs contain meaningful information, but these don't, really:
We may as well not bother indexing the URL content. To achieve that we need to assign the
urlfield to a different FieldType.
Instead of FullTextType, we'll use a StringType, which doesn't use an Analyzer to break up text into individual fields. Furthermore, we'll mark this StringType as unindexed, so that its content won't be searchable at all.
my $url_type = KinoSearch::FieldType::StringType( indexed => 0 ); $schema->spec_field( name => 'url', type => $url_type );
To observe the change in behavior, try searching for
us_constitutionboth before and after changing the Schema and re-indexing.
For a taste of other FieldType possibilities, try turning off
storedfor one or more fields.
my $content_type = KinoSearch::FieldType::FullTextType->new( analyzer => $polyanalyzer, stored => 0, );
urlmangles our results page, but since we're not displaying
content, turning it off for
contenthas no effect -- except on index size.
Analyzers play a crucial role in the behavior of FullTextType fields. In our next tutorial chapter, KinoSearch::Docs::Tutorial::Analysis, we'll see how changing up the Analyzer changes search results.
Copyright 2008-2009 Marvin Humphrey
See KinoSearch version 0.30.