Задать вопрос

Тел: +7 965 3737 888

649

Просмотров

5

Ответов

Sphinx Search ORM

<p>An ORM model for the Sphinx full-text search engine.</p>
<p>See http://www.sphinxsearch.com/ for more information.</p>
<p>It currently supports the following:</p>
class MyModel(models.Model):
    search = SphinxSearch()

MyModel.search.query('query')
MyModel.search.query('query').order_by('@weight', '@id', 'my_attribute')
MyModel.search.query('query').filter(my_attribute=5)
MyModel.search.query('query').filter(my_other_attribute=[5, 3,4])
MyModel.search.query('query').exclude(my_attribute=5)[0:10]
MyModel.search.query('query').count()

SphinxSearch().query('hello').on_index('model_myapp model_myotherapp')

<p>Returns an ordered list of the objects in your database.</p>
<p>-- Update:</p>
<p>New Methods:</p>
<ul><li>count()</li>
<li>index_on(&lt;str index&gt;)</li>
<li>extra(&lt;see django&gt;)</li>
<li>all() (does nothing)</li>
<li>select_related(&lt;see django&gt;)</li>
<li>group_by(&lt;str attribute&gt;, &lt;const function&gt;[, &lt;str sort&gt;)</li>
<li>weights(&lt;list weights&gt;)</li>
</ul>

Вопрос полезен? Да0/Нет0
file_4209.py(12.9Кб)
None

Ответы (5):

Ответbjschnei:23.09.2007
Ответ полезен? Да0/Нет0

are these lines of code really necessary? what is there purpose?

queryset = dict([(o.id, o) for o in qs]) results = [queryset[k['doc']] for k in results['matches'] if k['doc'] in queryset]

Ответbjschnei:04.09.2007
Ответ полезен? Да0/Нет0

oops, index name in sphinx.conf must be the same name as the table you are searching...works now...thanks!!!!

Ответbjschnei:04.09.2007
Ответ полезен? Да0/Нет0

i am getting:

Error in formatting: searchd error: invalid index 'xxxxx' specified in request

where xxxxx is the name of my table....anyone seen this?

Ответhelp:19.06.2007
Ответ полезен? Да0/Нет0

Do you create a new model just for Sphinx Search? For example if I have "post" model defined with all the fields, what do I need to do get Sphinx Search to work?

Can I do this?

class Post(models.Model):

field1,
field2,
...
fieldn

search = SphinxSearch()

Ответludo:26.05.2007
Ответ полезен? Да0/Нет0

import select is unnecessary, probably a leftover from the original sphinx Python driver.

Great job, can't wait to test it on my apps.