Added overridable weighting scheme through the use of a new setting named HAYSTACK_XAPIAN_WEIGHTING_SCHEME.

This commit is contained in:
David Sauve 2011-06-13 13:37:29 -07:00
parent cc8a5ad773
commit 6a7c2ef9bf
3 changed files with 8 additions and 2 deletions

View File

@ -23,4 +23,4 @@ Thanks to:
* Sym Roe for a patch that improved performance in "more-like-this" and suggestion the removal of FLAG_PARTIAL.
* liranz for pointing out a potential conflict with arguments pass into `SearchResult`
* Jacob Kaplan-Moss for pointing out that write permission shouldn't be required for searching.
* glassresistor for assistance troubleshooting an issue with boosting a phrase query.
* glassresistor for assistance troubleshooting an issue with boosting a phrase query & a patch to make weighting schemes overridable.

View File

@ -44,7 +44,11 @@ Installation
Configuration
-------------
As well as the flags described `here <http://docs.haystacksearch.org/dev/settings.html>`_, the xapian backend includes and additional `HAYSTACK_XAPIAN_FLAGS` variable to further configure how indexes are stored and manipulated. By default, this value is set to `FLAG_PHRASE | FLAG_BOOLEAN | FLAG_LOVEHATE | FLAG_WILDCARD | FLAG_PURE_NOT`. See the `Xapian documentation <http://xapian.org/docs/apidoc/html/classXapian_1_1QueryParser.html>`_ for further explanation of the available Xapian.QueryParser flags.
As well as the flags described `here <http://docs.haystacksearch.org/dev/settings.html>`_, the xapian backend includes two additional variables:
- `HAYSTACK_XAPIAN_FLAGS` -- used to further configure how indexes are stored and manipulated. By default, this value is set to `FLAG_PHRASE | FLAG_BOOLEAN | FLAG_LOVEHATE | FLAG_WILDCARD | FLAG_PURE_NOT`. See the `Xapian::QueryParser::feature_flag in the Xapian documentation <http://xapian.org/docs/apidoc/html/classXapian_1_1QueryParser.html>`_ for further explanation of the available Xapian.QueryParser flags.
- `HAYSTACK_XAPIAN_WEIGHTING_SCHEME` -- used to override the default weighting scheme used during search. `HAYSTACK_XAPIAN_WEIGHTING_SCHEME` is assumed to be a tuple that corepsonds to the arguments to a BM25Weight constructor. See `Xapian::BM25Weight::BM25Weight in the Xapian documentation <http://xapian.org/docs/apidoc/html/classXapian_1_1BM25Weight.html>`_ for further information.
Testing
-------

View File

@ -396,6 +396,8 @@ class SearchBackend(BaseSearchBackend):
)
enquire = xapian.Enquire(database)
if hasattr(settings, 'HAYSTACK_XAPIAN_WEIGHTING_SCHEME'):
enquire.set_weighting_scheme(xapian.BM25Weight(*settings.HAYSTACK_XAPIAN_WEIGHTING_SCHEME))
enquire.set_query(query)
if sort_by: