mirror of
https://github.com/Hopiu/xapian-haystack.git
synced 2026-05-11 16:53:14 +00:00
Fixed bug in 'mlt'. Was using not allowing additional_query_string, start_offset, and end_offset params
This commit is contained in:
parent
fa3245d73d
commit
051fe7ddd4
1 changed files with 13 additions and 2 deletions
|
|
@ -366,7 +366,8 @@ class SearchBackend(BaseSearchBackend):
|
|||
return 0
|
||||
return database.get_doccount()
|
||||
|
||||
def more_like_this(self, model_instance):
|
||||
def more_like_this(self, model_instance, additional_query_string=None,
|
||||
start_offset=0, end_offset=DEFAULT_MAX_RESULTS, **kwargs):
|
||||
"""
|
||||
Given a model instance, returns a result set of similar documents.
|
||||
|
||||
|
|
@ -374,6 +375,12 @@ class SearchBackend(BaseSearchBackend):
|
|||
`model_instance` -- The model instance to use as a basis for
|
||||
retrieving similar documents.
|
||||
|
||||
Optional arguments:
|
||||
`additional_query_string` -- An additional query string to narrow
|
||||
results
|
||||
`start_offset` -- The starting offset (default=0)
|
||||
`end_offset` -- The ending offset (default=None)
|
||||
|
||||
Returns:
|
||||
A dictionary with the following keys:
|
||||
`results` -- A list of `SearchResult`
|
||||
|
|
@ -402,10 +409,14 @@ class SearchBackend(BaseSearchBackend):
|
|||
query = xapian.Query(
|
||||
xapian.Query.OP_AND_NOT, [query, self.get_identifier(model_instance)]
|
||||
)
|
||||
if additional_query_string:
|
||||
query = xapian.Query(
|
||||
xapian.Query.OP_AND, [query, self._query(database, additional_query_string)]
|
||||
)
|
||||
enquire.set_query(query)
|
||||
|
||||
results = []
|
||||
matches = enquire.get_mset(0, DEFAULT_MAX_RESULTS)
|
||||
matches = enquire.get_mset(start_offset, end_offset)
|
||||
|
||||
for match in matches:
|
||||
document = match.get_document()
|
||||
|
|
|
|||
Loading…
Reference in a new issue