How to weigh results not taking into account document length?

31 views
Skip to first unread message

Richard Nichols III

unread,
Apr 15, 2020, 3:15:06 PM4/15/20
to Whoosh
Hi, what's the simplest way to get some results weighted without dividing by a log of document length? Basically I just want results in order of how many times any word from my search string appears in the document.

I tried this:

   with self.ix.searcher(weighting=scoring.WeightScorer(maxweight=1)) as searcher: #wtf do i do for maxweight?
      #was: with self.ix.searcher() as searcher:
        query = Or([Term("searchablecontent", token.text) for token in stream])
        results = searcher.search(query)

and I got this error:

  File "c:\limnoria\plugins\AIBot\plugin.py", line 46, in invalidCommand
    results = searcher.search(query)
  File "c:\python37-32\lib\site-packages\whoosh\searching.py", line 786, in search
    self.search_with_collector(q, c)
  File "c:\python37-32\lib\site-packages\whoosh\searching.py", line 817, in search_with_collector
    collector.prepare(self, q, context)
  File "c:\python37-32\lib\site-packages\whoosh\collectors.py", line 335, in prepare
    if top_searcher.weighting.use_final:
AttributeError: 'WeightScorer' object has no attribute 'use_final'

Thanks


Vito Piepoli

unread,
Apr 16, 2020, 4:35:04 AM4/16/20
to who...@googlegroups.com
Have you tried with "weighting=scoring.Frequency"?

--
You received this message because you are subscribed to the Google Groups "Whoosh" group.
To unsubscribe from this group and stop receiving emails from it, send an email to whoosh+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/whoosh/2401df1d-b692-4f1d-b4e3-15d24642d346%40googlegroups.com.

inhahe

unread,
Apr 16, 2020, 6:53:36 PM4/16/20
to who...@googlegroups.com
That seems to have worked, Thx.
Reply all
Reply to author
Forward
0 new messages