Форум сайта python.su
Доброго,
Есть такой код
from django.conf import settings from lib.sphinxsearch import SphinxClient, SPH_MATCH_EXTENDED, SPH_SORT_RELEVANCE, SPH_SORT_ATTR_ASC, SPH_SORT_ATTR_DESC, SPH_SORT_EXPR, SPH_SORT_EXTENDED, SPH_SORT_TIME_SEGMENTS, SPH_RANK_BM25, SPH_RANK_PROXIMITY_BM25, SPH_RANK_WORDCOUNT, SPH_RANK_SPH04 def sphinx_instance(): sphinx = SphinxClient() sphinx.SetServer(settings.SPHINX_SERVER, settings.SPHINX_PORT) sphinx.SetMatchMode(SPH_MATCH_EXTENDED) sphinx.SetSortMode(SPH_SORT_RELEVANCE) sphinx.SetRankingMode(SPH_RANK_SPH04) sphinx.SetLimits(0, 100000, 100000) return sphinx sphinx = sphinx_instance() result = sphinx.Query('usb', 'product')
$ mysql -P 9306 -h 0 mysql> select * from product where match('usb'); +--------+--------+---------+---------+-------------+------------+------------+------------+-------+------------+--------+------------+------------+ | id | weight | item_id | country | category_id | company_id | updated | price_min | image | verified | tariff | is_testing | model_name | +--------+--------+---------+---------+-------------+------------+------------+------------+-------+------------+--------+------------+------------+ | 246534 | 2803 | 246534 | 0 | 3430 | 17727 | 1429783486 | 100.000000 | 0 | 2905310389 | 1000 | 0 | 4 | +--------+--------+---------+---------+-------------+------------+------------+------------+-------+------------+--------+------------+------------+ 1 row in set (0.00 sec)
Офлайн