only use OP_WILDCARD for xapian >= 1.3.3

It's not available for earlier versions.
This commit is contained in:
djcb
2018-05-19 22:22:41 +03:00
parent 6290e4ad9a
commit 7a8d43dc5f
2 changed files with 12 additions and 1 deletions

View File

@ -17,6 +17,10 @@
** 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H*/
#include <xapian.h>
#include "parser/xapian.hh"
@ -52,12 +56,16 @@ xapian_query_op (const Mux::Tree& tree)
static Xapian::Query
maybe_wildcard (const Value* val, const std::string& str)
{
#ifndef XAPIAN_HAVE_OP_WILDCARD
return Xapian::Query(val->prefix + str);
#else
const auto vlen = str.length();
if (vlen <= 1 || str[vlen-1] != '*')
return Xapian::Query(val->prefix + str);
else
return Xapian::Query(Xapian::Query::OP_WILDCARD,
val->prefix + str.substr(0, vlen-1));
#endif/*XAPIAN_HAVE_OP_WILDCARD*/
}
static Xapian::Query