
barborak at basikgroup
Jun 26, 2008, 12:30 PM
Post #1 of 2
(738 views)
Permalink
|
|
error when query parser has no fields specified
|
|
Hello, I'm new to KinoSearch 0.162 and am having a small problem I hope someone can help me out with. I've created my index and am now querying it. My problem is that if I query (script below) without setting the fields option in the KinoSearch::QueryParser::QueryParser constructor, I get an error (below with stack trace) and no search results. If I add the fields option, I get no errors and the correct search results. From the examples, I understood that the fields option was not required but if it is, is their a public API to get the list of fields in an index? Thanks, Mike use KinoSearch::Searcher; use KinoSearch::Analysis::PolyAnalyzer; use KinoSearch::Search::QueryFilter; use KinoSearch::Search::TermQuery; use KinoSearch::QueryParser::QueryParser; my $analyzer = KinoSearch::Analysis::PolyAnalyzer->new( language => 'en' ); my $searcher = KinoSearch::Searcher->new( invindex => 'search', analyzer => $analyzer, ); my $query_parser = KinoSearch::QueryParser::QueryParser->new( analyzer => $analyzer, # fields => [ 'Event_title' ], default_boolop => 'AND', ); my $query = $query_parser->parse( lc ( $ARGV[0] ) ); my $hits = $searcher->search( query => $query ); while ( my $hit = $hits->fetch_hit_hashref ) { print "$hit->{__id}\n"; } here at C:/Tools/perl/site/5.8.8/lib/KinoSearch/Index/FieldInfos.pm line 78 KinoSearch::Index::FieldInfos::get_field_num('KinoSearch::Index::FieldInfos=HASH(0x31e265c)', 'undef') called at C:/Tools/perl/site/5.8.8/lib/KinoSearch/Index/Term.pm line 38 KinoSearch::Index::Term::get_termstring('KinoSearch::Index::Term=HASH(0x320bb2c)', 'KinoSearch::Index::FieldInfos=HASH(0x31e265c)') called at C:/Tools/perl/site/5.8.8/lib/KinoSearch/Index/TermInfosReader.pm line 57 KinoSearch::Index::TermInfosReader::fetch_term_info('KinoSearch::Index::TermInfosReader=HASH(0x3206ad0)', 'KinoSearch::Index::Term=HASH(0x320bb2c)') called at C:/Tools/perl/site/5.8.8/lib/KinoSearch/Index/SegReader.pm line 150 KinoSearch::Index::SegReader::doc_freq('KinoSearch::Index::SegReader=HASH(0x2cc01b8)', 'KinoSearch::Index::Term=HASH(0x320bb2c)') called at C:/Tools/perl/site/5.8.8/lib/KinoSearch/Searcher.pm line 135 KinoSearch::Searcher::doc_freq('KinoSearch::Searcher=HASH(0x31e1d20)', 'KinoSearch::Index::Term=HASH(0x320bb2c)') called at C:/Tools/perl/site/5.8.8/lib/KinoSearch/Search/Similarity.pm line 28 KinoSearch::Search::Similarity::idf('KinoSearch::Search::Similarity=SCALAR(0x31e1ce4)', 'KinoSearch::Index::Term=HASH(0x320bb2c)', 'KinoSearch::Searcher=HASH(0x31e1d20)') called at C:/Tools/perl/site/5.8.8/lib/KinoSearch/Search/TermQuery.pm line 66 KinoSearch::Search::TermWeight::init_instance('KinoSearch::Search::TermWeight=HASH(0x320bd60)') called at C:/Tools/perl/site/5.8.8/lib/KinoSearch/Util/Class.pm line 31 KinoSearch::Util::Class::new('KinoSearch::Search::TermWeight', 'parent', 'KinoSearch::Search::TermQuery=HASH(0x320bba4)', 'searcher', 'KinoSearch::Searcher=HASH(0x31e1d20)') called at C:/Tools/perl/site/5.8.8/lib/KinoSearch/Search/TermQuery.pm line 25 KinoSearch::Search::TermQuery::create_weight('KinoSearch::Search::TermQuery=HASH(0x320bba4)', 'KinoSearch::Searcher=HASH(0x31e1d20)') called at C:/Tools/perl/site/5.8.8/lib/KinoSearch/Search/Query.pm line 44 KinoSearch::Search::Query::to_weight('KinoSearch::Search::TermQuery=HASH(0x320bba4)', 'KinoSearch::Searcher=HASH(0x31e1d20)') called at C:/Tools/perl/site/5.8.8/lib/KinoSearch/Searcher.pm line 140 KinoSearch::Searcher::create_weight('KinoSearch::Searcher=HASH(0x31e1d20)', 'KinoSearch::Search::TermQuery=HASH(0x320bba4)') called at C:/Tools/perl/site/5.8.8/lib/KinoSearch/Search/Hits.pm line 39 KinoSearch::Search::Hits::init_instance('KinoSearch::Search::Hits=HASH(0x320bc94)') called at C:/Tools/perl/site/5.8.8/lib/KinoSearch/Util/Class.pm line 31 KinoSearch::Util::Class::new('KinoSearch::Search::Hits', 'searcher', 'KinoSearch::Searcher=HASH(0x31e1d20)', 'query', 'KinoSearch::Search::TermQuery=HASH(0x320bba4)', 'filter', 'undef', 'num_docs', 'undef', ...) called at C:/Tools/perl/site/5.8.8/lib/KinoSearch/Searcher.pm line 79 KinoSearch::Searcher::search('KinoSearch::Searcher=HASH(0x31e1d20)', 'query', 'KinoSearch::Search::TermQuery=HASH(0x320bba4)') called at search.pl line 22 Use of uninitialized value in exists at C:/Tools/perl/site/5.8.8/lib/KinoSearch/Index/FieldInfos.pm line 80.
|