1LucyX::Index::ByteBufDoUcsWerritCeorn(t3r)ibuted Perl DoLcuucmyeXn:t:aItnidoenx::ByteBufDocWriter(3)
2
3
4
6 LucyX::Index::ByteBufDocWriter - Write a Doc as a fixed-width byte
7 array.
8
10 Create an Architecture subclass which overrides register_doc_writer()
11 and register_doc_reader():
12
13 package MyArchitecture;
14 use base qw( Lucy::Plan::Architecture );
15 use LucyX::Index::ByteBufDocReader;
16 use LucyX::Index::ByteBufDocWriter;
17
18 sub register_doc_writer {
19 my ( $self, $seg_writer ) = @_;
20 my $doc_writer = LucyX::Index::ByteBufDocWriter->new(
21 width => 16,
22 field => 'value',
23 snapshot => $seg_writer->get_snapshot,
24 segment => $seg_writer->get_segment,
25 polyreader => $seg_writer->get_polyreader,
26 );
27 $seg_writer->register(
28 api => "Lucy::Index::DocReader",
29 component => $doc_writer,
30 );
31 $seg_writer->add_writer($doc_writer);
32 }
33
34 sub register_doc_reader {
35 my ( $self, $seg_reader ) = @_;
36 my $doc_reader = LucyX::Index::ByteBufDocReader->new(
37 width => 16,
38 field => 'value',
39 schema => $seg_reader->get_schema,
40 folder => $seg_reader->get_folder,
41 segments => $seg_reader->get_segments,
42 seg_tick => $seg_reader->get_seg_tick,
43 snapshot => $seg_reader->get_snapshot,
44 );
45 $seg_reader->register(
46 api => 'Lucy::Index::DocReader',
47 component => $doc_reader,
48 );
49 }
50
51 package MySchema;
52 use base qw( Lucy::Plan::Schema );
53
54 sub architecture { MyArchitecture->new }
55
56 Proceed as normal in your indexer app, making sure that every supplied
57 document supplies a valid value for the field in question:
58
59 $indexer->add_doc({
60 title => $title,
61 content => $content,
62 id => $id, # <---- Must meet spec.
63 });
64
65 Then, in your search app:
66
67 my $searcher = Lucy::Search::IndexSearcher->new(
68 index => '/path/to/index',
69 );
70 my $hits = $searcher->hits( query => $query );
71 while ( my $id = $hits->next ) {
72 my $real_doc = $external_document_source->fetch( $doc->{value} );
73 ...
74 }
75
77 This is a proof-of-concept class to demonstrate alternate
78 implementations for fetching documents. It is unsupported.
79
80
81
82perl v5.30.1 2020-01-30 LucyX::Index::ByteBufDocWriter(3)