I'm trying to implement full text search in web2py with whoosh backend 
using plugin_haystack.
 But when I try to use index.search() function inside some other function, 
it gives <type 'exceptions.AttributeError'> 'function' object has no 
attribute 'search'

table in db.py :
db.define_table('question',
            db.Field('body', 'text'),
            format = '%(id)s')


index = Haystack(db.question,backend=WhooshBackend,indexdir=
'applications/myapp/private/index')
index.indexes('body')

function defined in controller:
def search_questions(search_text):
    return index.search(body=search_text)

Error Traceback : Any suggestions on what is wrong here?

Traceback (most recent call last):
  File "H:\test\web2py_src\web2py\gluon\restricted.py", line 217, in restricted
    exec ccode in environment
  File "H:/test/web2py_src/web2py/applications/myapp/controllers/temp.py" 
<http://127.0.0.1:8000/admin/default/edit/discoursa/controllers/temp.py>, line 
116, in <module>
  File "H:\discoursa\web2py_src\web2py\gluon\globals.py", line 385, in <lambda>
    self._caller = lambda f: f()
  File "H:/test/web2py_src/web2py/applications/myapp/controllers/temp.py", line 
44, in temp
    ids = search_questions("testing whoosh")
  File "H:/test/web2py_src/web2py/applications/myapp/controllers/temp.py" 
<http://127.0.0.1:8000/admin/default/edit/discoursa/controllers/temp.py>, line 
22, in search_questions
    return index.search(body=search_text)
AttributeError: 'function' object has no attribute 'search'

Any suggestions on what is wrong here?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to