X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/8a6a5320edc2c8a2ed357463b61f161d5b295fbf..b9ba68208ebdb250dc4d4f8866cb834f5bd8764c:/doc/todo/different_search_engine.mdwn?ds=inline diff --git a/doc/todo/different_search_engine.mdwn b/doc/todo/different_search_engine.mdwn index 3737fb140..9d0fc92c9 100644 --- a/doc/todo/different_search_engine.mdwn +++ b/doc/todo/different_search_engine.mdwn @@ -1,6 +1,6 @@ [[done]], using xapian-omega! --[[Joey]] -After using it for a while, my feeling is that [[hyperestraier]], as used in +After using it for a while, my feeling is that hyperestraier, as used in the [[plugins/search]] plugin, is not robust enough for ikiwiki. It doesn't upgrade well, and it has a habit of sig-11 on certain input from time to time. @@ -33,35 +33,25 @@ Possibilities: written on the page would be indexed. Not text generated by directives, pulled in by inlining, etc. There's something to be said for that. And something to be said against it. It would also get markdown formatted - content, mostly, though it would still need to strip html. + content, mostly, though it would still need to strip html, and also + probably strip preprocessor directives too. * `sanitize` - Would get the htmlized content, so would need to strip html. - Preprocessor directive output would be indexed. + Preprocessor directive output would be indexed. Doesn't get a destpage + parameter, making optimisation hard. * `format` - Would get the entire html page, including the page template. Probably not a good choice as indexing the same template for each page is unnecessary. -Currently, a filter hook seems the best option. - The hook would remove any html from the content, and index it. -It would need to add the same document data that omindex would, as well as -adding the same special terms (see -http://xapian.org/docs/omega/overview.html "Boolean terms"). - -(Note that the U term is a bit tricky because I'll have to replicate -ominxes's hash_string() to hash terms > 240 chars.) +It would need to add the same document data that omindex would. The indexer (and deleter) will need a way to figure out the ids in xapian of the documents to delete. One way is storing the id of each page in the ikiwiki index. The other way would be adding a special term to the xapian db that can be -used with replace_document_by_term/delete_document_by_term. omindex uses -U as a term, and I guess I could just use that, and then map page -names to urls when deleting a page ... only real problem being the -hashing; a collision would be bad. - -At the moment, storing xapian ids in the ikiwiki index file seems like the -best approach. +used with replace_document_by_term/delete_document_by_term. +Hmm, let's use a term named "P". The hook should try to avoid re-indexing pages that have not changed since they were last indexed. One problem is that, if a page with an inline is @@ -136,7 +126,7 @@ Index: IkiWiki/Plugin/search.pm + $PLUCENE_DIR = $config{wikistatedir}.'/plucene'; +} + - sub import { #{{{ + sub import { - hook(type => "getopt", id => "hyperestraier", - call => \&getopt); - hook(type => "checkconfig", id => "hyperestraier", @@ -152,14 +142,14 @@ Index: IkiWiki/Plugin/search.pm call => \&change); - hook(type => "cgi", id => "hyperestraier", - call => \&cgi); - } # }}} + } --sub getopt () { #{{{ +-sub getopt () { - eval q{use Getopt::Long}; - error($@) if $@; - Getopt::Long::Configure('pass_through'); - GetOptions("estseek=s" => \$config{estseek}); --} #}}} +-} +sub writer { + init(); @@ -175,20 +165,20 @@ Index: IkiWiki/Plugin/search.pm + grep { defined pagetype($_) } @_; +} + - sub checkconfig () { #{{{ + sub checkconfig () { foreach my $required (qw(url cgiurl)) { if (! length $config{$required}) { @@ -36,112 +58,55 @@ } - } #}}} + } -my $form; --sub pagetemplate (@) { #{{{ +-sub pagetemplate (@) { - my %params=@_; - my $page=$params{page}; - my $template=$params{template}; +#my $form; -+#sub pagetemplate (@) { #{{{ ++#sub pagetemplate (@) { +# my %params=@_; +# my $page=$params{page}; +# my $template=$params{template}; @@ -203,7 +193,7 @@ Index: IkiWiki/Plugin/search.pm +# +# $template->param(searchform => $form); +# } -+#} #}}} ++#} - # Add search box to page header. - if ($template->query(name => "searchform")) { @@ -215,9 +205,9 @@ Index: IkiWiki/Plugin/search.pm - - $template->param(searchform => $form); - } --} #}}} +-} - - sub delete (@) { #{{{ + sub delete (@) { - debug(gettext("cleaning hyperestraier search index")); - estcmd("purge -cl"); - estcfg(); @@ -229,9 +219,9 @@ Index: IkiWiki/Plugin/search.pm + $reader->delete_term( Plucene::Index::Term->new({ field => "id", text => $_ })); + } + $reader->close; - } #}}} + } - sub change (@) { #{{{ + sub change (@) { - debug(gettext("updating hyperestraier search index")); - estcmd("gather -cm -bc -cl -sd", - map { @@ -260,9 +250,9 @@ Index: IkiWiki/Plugin/search.pm + $doc->add(Plucene::Document::Field->UnStored('text' => $data)); + $writer->add_document($doc); + } - } #}}} + } - --sub cgi ($) { #{{{ +-sub cgi ($) { - my $cgi=shift; - - if (defined $cgi->param('phrase') || defined $cgi->param("navi")) { @@ -270,10 +260,10 @@ Index: IkiWiki/Plugin/search.pm - chdir("$config{wikistatedir}/hyperestraier") || error("chdir: $!"); - exec("./".IkiWiki::basename($config{cgiurl})) || error("estseek.cgi failed"); - } --} #}}} +-} - -my $configured=0; --sub estcfg () { #{{{ +-sub estcfg () { - return if $configured; - $configured=1; - @@ -311,9 +301,9 @@ Index: IkiWiki/Plugin/search.pm - unlink($cgi); - my $estseek = defined $config{estseek} ? $config{estseek} : '/usr/lib/estraier/estseek.cgi'; - symlink($estseek, $cgi) || error("symlink $estseek $cgi: $!"); --} # }}} +-} - --sub estcmd ($;@) { #{{{ +-sub estcmd ($;@) { - my @params=split(' ', shift); - push @params, "-cl", "$config{wikistatedir}/hyperestraier"; - if (@_) { @@ -333,7 +323,7 @@ Index: IkiWiki/Plugin/search.pm - open(STDOUT, "/dev/null"); # shut it up (closing won't work) - exec("estcmd", @params) || error("can't run estcmd"); - } --} #}}} +-} - -1 +1;