[Xapian-discuss] Phrase query problem with python api

Victor Ng crankycoder at gmail.com
Thu Mar 15 04:08:13 GMT 2007


Hi all,

I'm pretty new to xapian and I can't seem to see what's wrong with this code.

      1 '''
      2 This module provides some examples of how to use the xapian API
      3 '''
      4
      5 import xapian
      6 def test_near():
      7     xapian.Query(xapian.Query.OP_PHRASE, 'abc', 'def')
      8     q_phrase = xapian.Query(xapian.Query.OP_PHRASE, ("smoke",
"test", "tuple"))
      9     q_xor = xapian.Query(xapian.Query.OP_XOR,
(xapian.Query('smoke'), q_phrase, 'string'))
     10     q_phrase_comp = xapian.Query(xapian.Query.OP_PHRASE,
(q_phrase, q_xor))

The query in line 10 bombs out with:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/nose-0.9.2-py2.4.egg/nose/case.py",
line 52, in runTest
    self.testFunc()
  File "/Users/victorng/dev/bzr_repo/test_xapian.py", line 10, in test_near
    q_phrase_comp = xapian.Query(xapian.Query.OP_PHRASE, (q_phrase, q_xor))
  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/xapian.py",
line 473, in __init__
    _xapian.Query_swiginit(self,_xapian.new_Query(*args))
RuntimeError: unknown error in Xapian


Aren't PHRASE queries allowed to take arbitrary subqueries or does it
only allow some kinds of subqueries?

vic



More information about the Xapian-discuss mailing list