1KinoSearch1::InvIndexerU(s3e)r Contributed Perl DocumentaKtiinoonSearch1::InvIndexer(3)
2
3
4

NAME

6       KinoSearch1::InvIndexer - build inverted indexes
7

SYNOPSIS

9           use KinoSearch1::InvIndexer;
10           use KinoSearch1::Analysis::PolyAnalyzer;
11
12           my $analyzer
13               = KinoSearch1::Analysis::PolyAnalyzer->new( language => 'en' );
14
15           my $invindexer = KinoSearch1::InvIndexer->new(
16               invindex => '/path/to/invindex',
17               create   => 1,
18               analyzer => $analyzer,
19           );
20
21           $invindexer->spec_field(
22               name  => 'title'
23               boost => 3,
24           );
25           $invindexer->spec_field( name => 'bodytext' );
26
27           while ( my ( $title, $bodytext ) = each %source_documents ) {
28               my $doc = $invindexer->new_doc($title);
29
30               $doc->set_value( title    => $title );
31               $doc->set_value( bodytext => $bodytext );
32
33               $invindexer->add_doc($doc);
34           }
35
36           $invindexer->finish;
37

DESCRIPTION

39       The InvIndexer class is KinoSearch1's primary tool for creating and
40       modifying inverted indexes, which may be searched using
41       KinoSearch1::Searcher.
42

METHODS

44   new
45           my $invindexer = KinoSearch1::InvIndexer->new(
46               invindex => '/path/to/invindex',  # required
47               create   => 1,                    # default: 0
48               analyzer => $analyzer,            # default: no-op Analyzer
49           );
50
51       Create an InvIndexer object.
52
53invindex - can be either a filepath, or an InvIndex subclass such
54           as KinoSearch1::Store::FSInvIndex or
55           KinoSearch1::Store::RAMInvIndex.
56
57create - create a new invindex, clobbering an existing one if
58           necessary.
59
60analyzer - an object which subclasses
61           KinoSearch1::Analysis::Analyzer, such as a PolyAnalyzer.
62
63   spec_field
64           $invindexer->spec_field(
65               name       => 'url',      # required
66               boost      => 1,          # default: 1,
67               analyzer   => undef,      # default: analyzer spec'd in new()
68               indexed    => 0,          # default: 1
69               analyzed   => 0,          # default: 1
70               stored     => 1,          # default: 1
71               compressed => 0,          # default: 0
72               vectorized => 0,          # default: 1
73           );
74
75       Define a field.
76
77name - the field's name.
78
79boost - A multiplier which determines how much a field contributes
80           to a document's score.
81
82analyzer - By default, all indexed fields are analyzed using the
83           analyzer that was supplied to new().  Supplying an alternate for a
84           given field overrides the primary analyzer.
85
86indexed - index the field, so that it can be searched later.
87
88analyzed - analyze the field, using the relevant Analyzer.  Fields
89           such as "category" or "product_number" might be indexed but not
90           analyzed.
91
92stored - store the field, so that it can be retrieved when the
93           document turns up in a search.
94
95compressed - compress the stored field, using the zlib compression
96           algorithm.
97
98vectorized - store the field's "term vectors", which are required
99           by KinoSearch1::Highlight::Highlighter for excerpt selection and
100           search term highlighting.
101
102   new_doc
103           my $doc = $invindexer->new_doc;
104
105       Spawn an empty KinoSearch1::Document::Doc object, primed to accept
106       values for the fields spec'd by spec_field.
107
108   add_doc
109           $invindexer->add_doc($doc);
110
111       Add a document to the invindex.
112
113   add_invindexes
114           my $invindexer = KinoSearch1::InvIndexer->new(
115               invindex => $invindex,
116               analyzer => $analyzer,
117           );
118           $invindexer->add_invindexes( $another_invindex, $yet_another_invindex );
119           $invindexer->finish;
120
121       Absorb existing invindexes into this one.  May only be called once per
122       InvIndexer.  add_invindexes() and add_doc() cannot be called on the
123       same InvIndexer.
124
125   delete_docs_by_term
126           my $term = KinoSearch1::Index::Term->new( 'id', $unique_id );
127           $invindexer->delete_docs_by_term($term);
128
129       Mark any document which contains the supplied term as deleted, so that
130       it will be excluded from search results.  For more info, see Deletions
131       in KinoSearch1::Docs::FileFormat.
132
133   finish
134           $invindexer->finish(
135               optimize => 1, # default: 0
136           );
137
138       Finish the invindex.  Invalidates the InvIndexer.  Takes one hash-style
139       parameter.
140
141optimize - If optimize is set to 1, the invindex will be collapsed
142           to its most compact form, which will yield the fastest queries.
143
145       Copyright 2005-2010 Marvin Humphrey
146

LICENSE, DISCLAIMER, BUGS, etc.

148       See KinoSearch1 version 1.01.
149
150
151
152perl v5.32.1                      2021-01-27        KinoSearch1::InvIndexer(3)
Impressum