lucy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gerald Richter <rich...@ecos.de>
Subject Re: [lucy-user] how to get distinct values of a field
Date Tue, 03 Nov 2015 12:32:29 GMT
That works great!

Thanks

Gerald


Am 02.11.2015 um 14:14 schrieb Nick Wellnhofer:
>    my $index = Lucy::Index::IndexReader->open(index => $path_to_index);
>     my $lex_reader = $index->obtain('Lucy::Index::LexiconReader');
>     my $lexicon = $lex_reader->lexicon(field => $field_name);
>     my @terms;
>
>     while ($lexicon->next) {
>         push(@terms, $lexicon->get_term);
>     }
>
> Depending on the size of your index and the number of segments, it 
> might be more efficient to merge the terms from multiple segments 
> manually:
>
>     my $index = Lucy::Index::IndexReader->open(index => $path_to_index);
>     my $seg_readers = $index->seg_readers;
>     my %term_hash;
>
>     for my $seg_reader (@$seg_readers) {
>         my $lex_reader = 
> $seg_reader->obtain('Lucy::Index::LexiconReader');
>         my $lexicon = $lex_reader->lexicon(field => $field_name);
>
>         while ($lexicon->next) {
>             my $term = $lexicon->get_term;
>             $term_hash{$term} = undef;
>         }
>     }
>
>     my @terms = keys(%term_hash); 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message