Re: [Xapian-discuss] Wildcard search?

roki roki rokiroki at gmx.net
Tue Jul 5 08:48:19 BST 2005


Thanks!

> On Mon, Jul 04, 2005 at 02:34:17PM +0200, roki roki wrote:
> > is it possible to implement wildcard (at right side) search in xapian?
> 
> Yes - create a TermIterator using Database::allterms_begin(), skip_to()
> the prefix, then read terms which match the prefix and OR them together
> like so:
> 
>     TermIterator t = db.allterms_begin();
>     t.skip_to(name);
>     Query q;
>     while (t != db.allterms_end() && (*t).substr(0, name.size()) == name)
> {
>         if (q.empty()) {
>             q = Query(*t, 1, pos);
>         } else {
>             q = Query(Query::OP_OR, q, Query(*t, 1, pos));
>         }
>         ++t;
>     }
> 
> I've just checked this in for the QueryParser class.  Disabled by default
> since not everyone will want to allow it - pass
> Xapian::QueryParser::FLAG_WILDCARD in the new bitmask parameter to
> parse_query
> to turn it on.
> 
> Cheers,
>     Olly
> 

-- 
Weitersagen: GMX DSL-Flatrates mit Tempo-Garantie!
Ab 4,99 Euro/Monat: http://www.gmx.net/de/go/dsl



More information about the Xapian-discuss mailing list