[Grok-dev] Assertion error when quering TextIndex

Kevin Smith kevin at mcweekly.com
Tue Jun 26 12:43:54 EDT 2007


Here's some sample code.

# setup index
class SearchableTextIndex(grok.Indexes):
    grok.site(MySite)
    grok.context(ISearchableText)

    searchabletext  = index.Text()

# search function
from hurry.query.query import Query, Text
def search_text(text):
    results = Query().searchResults(
        Text( ('', 'searchabletext'), text)
        )
    return results


HTH,

Kevin Smith

Sebastian Ware wrote:
> I can't find an example in the DocTest that performs a TextIndex 
> search. It only has FieldIndex, SetIndex and ValueIndex 
> (hurry.query.0.9.2). I try to mimic the FieldIndex search (that works) 
> but I get an assertion error.
>
> I can see the "text_body' index in the Zope 3 management screens, and 
> it would shows 3 documents and 53 words indexed.
>
> This is the traceback:
>
>   File 
> "/Users/sebastianware/GrokProjects/ProtonCMS/src/protoncms/app.py", 
> line 32, in content_list
>     result = Query().searchResults(query.Eq(('proton_catalog', 
> 'text_body'), search_term))
>   File 
> "/Users/sebastianware/GrokProjects/ProtonCMS/eggs/hurry.query-0.9.2-py2.4.egg/hurry/query/query.py", 
> line 20, in searchResults
>     results = query.apply()
>   File 
> "/Users/sebastianware/GrokProjects/ProtonCMS/eggs/hurry.query-0.9.2-py2.4.egg/hurry/query/query.py", 
> line 144, in apply
>     return self.getIndex().apply((self.value, self.value))
>   File 
> "/Users/sebastianware/GrokProjects/ProtonCMS/eggs/hurry.query-0.9.2-py2.4.egg/hurry/query/query.py", 
> line 134, in getIndex
>     assert IFieldIndex.providedBy(index)
> AssertionError
>
> Mvh Sebastian
>
>
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev
>


More information about the Grok-dev mailing list