Using NestedChildren as part of a query

27 views
Skip to first unread message

Jordan Yelloz

unread,
Mar 30, 2013, 5:06:38 PM3/30/13
to who...@googlegroups.com
I have been evaluating Whoosh for a while and I was trying to make some use of the NestedChildren query. I am using the example from the page http://pythonhosted.org/Whoosh/nested.html#using-nested-document-indexing but I added a "returns" field to the schema which should describe the return type of each of the documents which represent a method.

If I want to find all the methods of the "Calculator" class which have a "void" return type, I should be able to use the query:
calculator_methods = NestedChildren(
   
Term('kind', u'class'),
   
Term('name', u'Calculator')
)
void_methods
= Term('returns', u'void')

void_calculator_methods
= calculator_methods & void_methods

When I perform a search on the query object "void_calculator_methods" I get a ReadTooFar error.
I have attached a full testcase which breaks against whoosh 2.4.1 and the latest from the mercurial repository.
Is this a bug or am I not using the queries correctly?
nestedchildren_readtoofar_test.py

Jordan Yelloz

unread,
Mar 30, 2013, 9:27:43 PM3/30/13
to who...@googlegroups.com
It seems that using the "filter" argument to the search method allows me to make these queries without filtering the results externally.

The code:
calculator_methods = NestedChildren(
   
Term('kind', u'class'),
   
Term('name', u'Calculator')
)
void_methods
= Term('returns', u'void')

# ...

s
.search(calculator_methods, filter=void_methods)

works for me.
Reply all
Reply to author
Forward
0 new messages