[Xapian-tickets] [Xapian] #407: Explicit "~" does not look for synonym when using FLAG_PARTIAL

Xapian nobody at xapian.org
Sat Oct 17 16:40:39 BST 2009


#407: Explicit "~" does not look for synonym when using FLAG_PARTIAL
-------------------------+--------------------------------------------------
 Reporter:  olinux       |       Owner:  olly
     Type:  defect       |      Status:  new 
 Priority:  normal       |   Milestone:      
Component:  QueryParser  |     Version:      
 Severity:  normal       |    Keywords:      
Blockedby:               |    Platform:  All 
 Blocking:               |  
-------------------------+--------------------------------------------------
 Query parser does not look for synonyms when FLAG_PARTIAL is combined with
 FLAG_AUTO_SYNONYMS or FLAG_SYNONYM

 '''Example queries'''

  * hello
  * ~hello
  * hello world
  * ~hello world
  * world ~hello

 '''Example'''

 Create database, add synonyms and parse above queries

 Problems are indicated by "PROBLEM" in comments below.

 {{{
 // create database
 $xapianDatabasePath = '/tmp/xapianSynonymTest';
 $db = new XapianWritableDatabase($xapianDatabasePath,
 Xapian::DB_CREATE_OR_OVERWRITE);

 $db->add_synonym('hello', 'hi');
 $db->add_synonym('hello', 'howdy');

 $db = null;

 // run some queries
 $db = new XapianDatabase($xapianDatabasePath);
 $enquire = new XapianEnquire($db);
 $qp = new XapianQueryParser();
 $stemmer = new XapianStem('english');
 $qp->set_stemmer($stemmer);
 $qp->set_database($db);

 $xapianFlags = XapianQueryParser::FLAG_BOOLEAN |
 XapianQueryParser::FLAG_AUTO_SYNONYMS;
 echo $xapianFlags . '<br>';

 // works as expected
 // Xapian::Query((hello:(pos=1) OR hi:(pos=1) OR howdy:(pos=1)))
 $query = $qp->parse_query('hello', $xapianFlags);
 echo $query->get_description() . '<br>';

 // works as expected
 // Xapian::Query((hello:(pos=1) OR hi:(pos=1) OR howdy:(pos=1)))
 $query = $qp->parse_query('~hello', $xapianFlags);
 echo $query->get_description() . '<br>';

 // works as expected
 // Xapian::Query((hello:(pos=1) OR hi:(pos=1) OR howdy:(pos=1) OR
 world:(pos=2)))
 $query = $qp->parse_query('hello world', $xapianFlags);
 echo $query->get_description() . '<br>';

 // works as expected
 // Xapian::Query((hello:(pos=1) OR hi:(pos=1) OR howdy:(pos=1) OR
 world:(pos=2)))
 $query = $qp->parse_query('~hello world', $xapianFlags);
 echo $query->get_description() . '<br>';

 $xapianFlags = XapianQueryParser::FLAG_BOOLEAN |
 XapianQueryParser::FLAG_PARTIAL | XapianQueryParser::FLAG_AUTO_SYNONYMS;
 echo $xapianFlags . '<br>';

 // works as expected
 // Xapian::Query(hello:(pos=1))
 $query = $qp->parse_query('hello', $xapianFlags);
 echo $query->get_description() . '<br>';

 // PROBLEM - EXPLICIT "~" SHOULD FORCE LOOK FOR A SYNONYM
 // Xapian::Query(hello:(pos=1))
 $query = $qp->parse_query('~hello', $xapianFlags);
 echo $query->get_description() . '<br>';

 // works as expected
 // Xapian::Query((hello:(pos=1) OR hi:(pos=1) OR howdy:(pos=1) OR
 world:(pos=2)))
 $query = $qp->parse_query('hello world', $xapianFlags);
 echo $query->get_description() . '<br>';

 // works as expected
 // Xapian::Query((hello:(pos=1) OR hi:(pos=1) OR howdy:(pos=1) OR
 world:(pos=2)))
 $query = $qp->parse_query('~hello world', $xapianFlags);
 echo $query->get_description() . '<br>';

 // PROBLEM - EXPLICIT "~" SHOULD FORCE LOOK FOR A SYNONYM
 // Xapian::Query((hello:(pos=1) OR hi:(pos=1) OR howdy:(pos=1) OR
 world:(pos=2)))
 $query = $qp->parse_query('world ~hello', $xapianFlags);
 echo $query->get_description() . '<br>';

 $xapianFlags = XapianQueryParser::FLAG_BOOLEAN |
 XapianQueryParser::FLAG_PARTIAL | XapianQueryParser::FLAG_SYNONYM;
 echo $xapianFlags . '<br>';

 // works as expected
 // Xapian::Query(hello:(pos=1))
 $query = $qp->parse_query('hello', $xapianFlags);
 echo $query->get_description() . '<br>';

 // PROBLEM - EXPLICIT "~" SHOULD FORCE LOOK FOR A SYNONYM
 // Xapian::Query(hello:(pos=1))
 $query = $qp->parse_query('~hello', $xapianFlags);
 echo $query->get_description() . '<br>';

 // works as expected
 // Xapian::Query((hello:(pos=1) OR world:(pos=2)))
 $query = $qp->parse_query('hello world', $xapianFlags);
 echo $query->get_description() . '<br>';

 // works as expected
 // Xapian::Query((hello:(pos=1) OR hi:(pos=1) OR howdy:(pos=1) OR
 world:(pos=2)))
 $query = $qp->parse_query('~hello world', $xapianFlags);
 echo $query->get_description() . '<br>';
 }}}

-- 
Ticket URL: <http://trac.xapian.org/ticket/407>
Xapian <http://xapian.org/>
Xapian



More information about the Xapian-tickets mailing list