[Xapian-tickets] [Xapian] #256: Bug when i switch from a sorting mode to an other in python
Xapian
nobody at xapian.org
Sat Apr 2 07:09:06 BST 2016
#256: Bug when i switch from a sorting mode to an other in python
----------------------------+---------------------------
Reporter: versmisse | Owner: olly
Type: defect | Status: closed
Priority: normal | Milestone: 1.0.7
Component: Library API | Version: 1.0.6
Severity: normal | Resolution: fixed
Keywords: Enquire python | Blocked By:
Blocking: | Operating System: All
----------------------------+---------------------------
Description changed by mariakatosvich:
Old description:
> Hello,
>
> I'm a French developer and i really want to use xapian for a project. We
> already have a "catalog" object but it is not efficient enough.
>
> I have already written a good part of the code (in python), but i have a
> problem with Enquire. When i use two different sorters and the first one
> no longer exists (simulated by a "del" in the snippet), i have an error.
>
> I simulate my problem with the following snippet that crashes with a
> beautiful segmentation fault
> {{{
> #!/usr/bin/python
> # -*- coding: UTF-8 -*-
>
> from xapian import (WritableDatabase, DB_CREATE_OR_OPEN, Document,
> Query, Enquire, MultiValueSorter,
> sortable_serialise)
>
> db = WritableDatabase('my_db', DB_CREATE_OR_OPEN)
>
> doc1 = Document()
> doc1.add_posting('foo', 0)
> doc1.add_value(0, sortable_serialise(1))
> doc1.add_value(1, 'doc1')
>
> doc2 = Document()
> doc2.add_posting('foo', 0)
> doc2.add_value(0, sortable_serialise(2))
> doc2.add_value(1, 'doc2')
>
> db.add_document(doc1)
> db.add_document(doc2)
>
> enquire = Enquire(db)
> enquire.set_query(Query(''))
>
> sorter = MultiValueSorter()
> sorter.add(0)
> enquire.set_sort_by_key_then_relevance(sorter)
> for doc in enquire.get_mset(0,10):
> print doc.get_document().get_value(1)
>
> del sorter
>
> enquire.set_sort_by_value_then_relevance(0)
> for doc in enquire.get_mset(0,10):
> print doc.get_document().get_value(1)
> }}}
> When i delete the "del sorter" line, there is not problem.
> Is it a bug or is it only my fault?
> Do we must do a new Enquire instance for each sort?
>
> Thanks you in advance for your answer.
> And thanks you very much for your project.
>
> Best regards,
> David Versmisse.
New description:
Hello,
I'm a French developer and i really want to use xapian for a project. We
already have a "catalog" object but it is not efficient enough.
I have already written a good part of the code (in python), but i have a
problem with Enquire. When i use two different sorters and the first one
no longer exists (simulated by a "del" in the snippet), i have an error.
http://www.qwiknumbers.com/bt-customer-service-number
I simulate my problem with the following snippet that crashes with a
beautiful segmentation fault
{{{
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from xapian import (WritableDatabase, DB_CREATE_OR_OPEN, Document,
Query, Enquire, MultiValueSorter,
sortable_serialise)
db = WritableDatabase('my_db', DB_CREATE_OR_OPEN)
doc1 = Document()
doc1.add_posting('foo', 0)
doc1.add_value(0, sortable_serialise(1))
doc1.add_value(1, 'doc1')
doc2 = Document()
doc2.add_posting('foo', 0)
doc2.add_value(0, sortable_serialise(2))
doc2.add_value(1, 'doc2')
db.add_document(doc1)
db.add_document(doc2)
enquire = Enquire(db)
enquire.set_query(Query(''))
sorter = MultiValueSorter()
sorter.add(0)
enquire.set_sort_by_key_then_relevance(sorter)
for doc in enquire.get_mset(0,10):
print doc.get_document().get_value(1)
del sorter
enquire.set_sort_by_value_then_relevance(0)
for doc in enquire.get_mset(0,10):
print doc.get_document().get_value(1)
}}}
When i delete the "del sorter" line, there is not problem.
Is it a bug or is it only my fault?
Do we must do a new Enquire instance for each sort?
Thanks you in advance for your answer.
And thanks you very much for your project.
Best regards,
David Versmisse.
--
--
Ticket URL: <https://trac.xapian.org/ticket/256#comment:7>
Xapian <//xapian.org/>
Xapian
More information about the Xapian-tickets
mailing list