Xapian::Query
RegexpFieldProcessor::operator() (const std::string & str)
{
+ if (str.size () == 0)
+ return Xapian::Query(Xapian::Query::OP_AND_NOT,
+ Xapian::Query::MatchAll,
+ Xapian::Query (Xapian::Query::OP_WILDCARD, term_prefix));
+
if (str.at (0) == '/') {
if (str.at (str.size () - 1) == '/'){
RegexpPostingSource *postings = new RegexpPostingSource (slot, str.substr(1,str.size () - 2));
} else {
/* TODO replace this with a nicer API level triggering of
* phrase parsing, when possible */
- std::string quoted='"' + str + '"';
- return parser.parse_query (quoted, NOTMUCH_QUERY_PARSER_FLAGS, term_prefix);
+ std::string query_str;
+
+ if (str.find (' ') != std::string::npos)
+ query_str = '"' + str + '"';
+ else
+ query_str = str;
+
+ return parser.parse_query (query_str, NOTMUCH_QUERY_PARSER_FLAGS, term_prefix);
}
}
#endif