1Lucy::Docs::Tutorial::FUiseelrdTCyopnetTruitbourtieLadulc(Py3e:)r:lDoDcosc:u:mTeunttoartiiaoln::FieldTypeTutorial(3)
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 Xfull textX fields, they are all
20       searchable X including the "url" field, a dubious choice.  Some URLs
21       contain meaningful information, but these donXt, 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, weXll use a StringType, which doesnXt use an
30       Analyzer to break up text into individual fields.  Furthermore, weXll
31       mark this StringType as unindexed, so that its content wonXt 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 XstoredX
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 weXre not displaying "content", turning it off for
51       "content" has no effect X 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, weXll see how changing
56       up the Analyzer changes search results.
57
58
59
60perl v5.36.0                      202L2u-c0y7:-:2D2ocs::Tutorial::FieldTypeTutorial(3)
Impressum