1Lucy::Docs::Tutorial::FUiseelrdTCyopnetTruitbouLrtuiecadyl:(P:3eDpromlc)sD:o:cTuumteonrtiaatli:o:nFieldTypeTutorial(3pm)
2
3
4

NAME

6       Lucy::Docs::Tutorial::FieldTypeTutorial - Specify per-field properties
7       and behaviors.
8

DESCRIPTION

10       The Schema we used in the last chapter specifies three fields:
11
12           my $type = Lucy::Plan::FullTextType->new(
13               analyzer => $easyanalyzer,
14           );
15           $schema->spec_field( name => 'title',   type => $type );
16           $schema->spec_field( name => 'content', type => $type );
17           $schema->spec_field( name => 'url',     type => $type );
18
19       Since they are all defined as “full text” fields, they are all
20       searchable – including the "url" field, a dubious choice.  Some URLs
21       contain meaningful information, but these don’t, really:
22
23           http://example.com/us_constitution/amend1.txt
24
25       We may as well not bother indexing the URL content.  To achieve that we
26       need to assign the "url" field to a different FieldType.
27
28   StringType
29       Instead of FullTextType, we’ll use a StringType, which doesn’t use an
30       Analyzer to break up text into individual fields.  Furthermore, we’ll
31       mark this StringType as unindexed, so that its content won’t be
32       searchable at all.
33
34           my $url_type = Lucy::Plan::StringType->new( indexed => 0 );
35           $schema->spec_field( name => 'url', type => $url_type );
36
37       To observe the change in behavior, try searching for "us_constitution"
38       both before and after changing the Schema and re-indexing.
39
40   Toggling ‘stored’
41       For a taste of other FieldType possibilities, try turning off "stored"
42       for one or more fields.
43
44           my $content_type = Lucy::Plan::FullTextType->new(
45               analyzer => $easyanalyzer,
46               stored   => 0,
47           );
48
49       Turning off "stored" for either "title" or "url" mangles our results
50       page, but since we’re not displaying "content", turning it off for
51       "content" has no effect – except on index size.
52
53   Analyzers up next
54       Analyzers play a crucial role in the behavior of FullTextType fields.
55       In our next tutorial chapter, AnalysisTutorial, we’ll see how changing
56       up the Analyzer changes search results.
57
58
59
60perl v5.38.0                      2L0u2c3y-:0:7D-o2c0s::Tutorial::FieldTypeTutorial(3pm)
Impressum