MultiFacet problem

34 views
Skip to first unread message

Vitalii Mazur

unread,
May 20, 2013, 8:53:50 AM5/20/13
to who...@googlegroups.com
I try to use sorting.MultiFacet in my project for cascading groupping. My code is:

>>> ix = open_dir("./finbroker/whoosh", indexname="deposits")
>>> searcher = ix.searcher()
>>> from whoosh.qparser import QueryParser
>>> from finbroker.whoosh.deposits import deposits_schema
>>> parser = QueryParser(u"rid:{0 to]", schema=deposits_schema)
>>> parser = QueryParser(u"rid", schema=deposits_schema)
>>> query = parser.parse(u"rid:{0 to]")
>>> facet = sorting.MultiFacet("days", "month")
>>> results = searcher.search(query, groupedby=facet)
Traceback (most recent call last):
  File "<pyshell#16>", line 1, in <module>
    results = searcher.search(query, groupedby=facet)
  File "build/bdist.linux-i686/egg/whoosh/searching.py", line 762, in search
    self.search_with_collector(q, c)
  File "build/bdist.linux-i686/egg/whoosh/searching.py", line 803, in search_with_collector
    collector.set_subsearcher(subsearcher, offset)
  File "build/bdist.linux-i686/egg/whoosh/collectors.py", line 675, in set_subsearcher
    categorizer.set_searcher(child.subsearcher, child.offset)
  File "build/bdist.linux-i686/egg/whoosh/sorting.py", line 764, in set_searcher
    catter.set_searcher(segment_searcher, docoffset)
  File "build/bdist.linux-i686/egg/whoosh/sorting.py", line 235, in set_searcher
    self.fieldcache = r.fieldcache(self.fieldname)
  File "build/bdist.linux-i686/egg/whoosh/filedb/filereading.py", line 360, in fieldcache
    fc = FieldCache.from_field(self, fieldname)
  File "build/bdist.linux-i686/egg/whoosh/filedb/fieldcache.py", line 164, in from_field
    field = ixreader.schema[fieldname]
  File "build/bdist.linux-i686/egg/whoosh/fields.py", line 990, in __getitem__
    raise KeyError("No field named %r" % (name,))
KeyError: "No field named 'd'"

What I'm doing wrong?
Thank you.

Thomas Waldmann

unread,
May 22, 2013, 3:53:31 AM5/22/13
to who...@googlegroups.com
Not sure, but the docs of MultiFacet seem a bit erroneous / inconsistent - but I guess the first parameter has to be a LIST of facets.

As you are giving a simple string "days" there, it'll take that as list of "d", "a", "y", "s".

Just an idea. If you find out the correct way, it would be nice if you could proofread and submit a patch to fix / clarify the docs.



Reply all
Reply to author
Forward
0 new messages