comments,formatting
This commit is contained in:
parent
308bec2ba8
commit
844f4f831a
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: searchdata.cpp,v 1.17 2007-06-22 06:14:04 dockes Exp $ (C) 2006 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: searchdata.cpp,v 1.18 2007-09-20 08:43:12 dockes Exp $ (C) 2006 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -366,18 +366,25 @@ bool StringToXapianQ::processUserString(const string &iq,
|
|||||||
it != phrases.end(); it++) {
|
it != phrases.end(); it++) {
|
||||||
LOGDEB(("strToXapianQ: phrase or word: [%s]\n", it->c_str()));
|
LOGDEB(("strToXapianQ: phrase or word: [%s]\n", it->c_str()));
|
||||||
|
|
||||||
// If there are both spans and single words in this element,
|
// If there are multiple spans in this element, including
|
||||||
// we need to use a word split, else a phrase query including
|
// at least one composite, we need to use a word split,
|
||||||
// a span would fail if we didn't adjust the proximity to
|
// else a phrase query including a span would fail.
|
||||||
// account for the additional span term which is complicated.
|
// (other possible solution: adjust slack to account for the
|
||||||
|
// additional position increase?)
|
||||||
|
// Ex: "term0@term01 term1" is onlyspans-split as:
|
||||||
|
// 0 term0@term01 0 12
|
||||||
|
// 2 term1 13 18
|
||||||
|
// The position of term1 is 2, not 1, so the phrase search would
|
||||||
|
// fail. We search for "term0 term01 term1" instead, which may
|
||||||
|
// have worse performance, but will succeed.
|
||||||
wsQData splitDataS(stops), splitDataW(stops);
|
wsQData splitDataS(stops), splitDataW(stops);
|
||||||
TextSplit splitterS(&splitDataS, (TextSplit::Flags)
|
TextSplit splitterS(&splitDataS,
|
||||||
(TextSplit::TXTS_ONLYSPANS |
|
TextSplit::Flags(TextSplit::TXTS_ONLYSPANS |
|
||||||
TextSplit::TXTS_KEEPWILD));
|
TextSplit::TXTS_KEEPWILD));
|
||||||
splitterS.text_to_words(*it);
|
splitterS.text_to_words(*it);
|
||||||
TextSplit splitterW(&splitDataW, (TextSplit::Flags)
|
TextSplit splitterW(&splitDataW,
|
||||||
(TextSplit::TXTS_NOSPANS |
|
TextSplit::Flags(TextSplit::TXTS_NOSPANS |
|
||||||
TextSplit::TXTS_KEEPWILD));
|
TextSplit::TXTS_KEEPWILD));
|
||||||
splitterW.text_to_words(*it);
|
splitterW.text_to_words(*it);
|
||||||
wsQData *splitData = &splitDataS;
|
wsQData *splitData = &splitDataS;
|
||||||
if (splitDataS.terms.size() > 1 &&
|
if (splitDataS.terms.size() > 1 &&
|
||||||
@ -389,12 +396,12 @@ bool StringToXapianQ::processUserString(const string &iq,
|
|||||||
switch (splitData->terms.size()) {
|
switch (splitData->terms.size()) {
|
||||||
case 0: continue;// ??
|
case 0: continue;// ??
|
||||||
case 1:
|
case 1:
|
||||||
// Not a real phrase: one term. Still may be expanded
|
// Just a term. Still may be expanded (by stem or
|
||||||
// (stem or wildcard)
|
// wildcard) to an OR list.
|
||||||
{
|
{
|
||||||
string term = splitData->terms.front();
|
string term = splitData->terms.front();
|
||||||
list<string> exp;
|
list<string> exp;
|
||||||
string sterm;
|
string sterm; // dumb version of user term
|
||||||
stripExpandTerm(false, term, exp, sterm);
|
stripExpandTerm(false, term, exp, sterm);
|
||||||
m_terms.insert(m_terms.end(), exp.begin(), exp.end());
|
m_terms.insert(m_terms.end(), exp.begin(), exp.end());
|
||||||
// Push either term or OR of stem-expanded set
|
// Push either term or OR of stem-expanded set
|
||||||
@ -417,10 +424,11 @@ bool StringToXapianQ::processUserString(const string &iq,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Phrase/near: transform into a PHRASE or NEAR xapian
|
// Element had several terms: transform into a PHRASE
|
||||||
// query, the element of which can themselves be OR
|
// or NEAR xapian query, the elements of which can
|
||||||
// queries if the terms get expanded by stemming or
|
// themselves be OR queries if the terms get expanded
|
||||||
// wildcards (we don't do stemming for PHRASE though)
|
// by stemming or wildcards (we don't do stemming for
|
||||||
|
// PHRASE though)
|
||||||
Xapian::Query::op op = useNear ? Xapian::Query::OP_NEAR :
|
Xapian::Query::op op = useNear ? Xapian::Query::OP_NEAR :
|
||||||
Xapian::Query::OP_PHRASE;
|
Xapian::Query::OP_PHRASE;
|
||||||
list<Xapian::Query> orqueries;
|
list<Xapian::Query> orqueries;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user