2009-11-20 6 views
1

django-sphinx 문서는 django-sphinx 계층이 여러 인덱스에 대한 기본적인 쿼리를 지원함을 보여줍니다. django-sphinx에서 다중 색인 쿼리하기

from djangosphinx.models import SphinxSearch 

SphinxSearch('index1 index2 index3').query('hello') 

http://github.com/dcramer/django-sphinx/blob/master/README.rst

그것은 SphinxSearch 함수 쿼리를 포함하지 않는 것 같다(). 또한 django-sphinx 문서에서 언급 한 것처럼 sphinx.conf sql_query 구성에 content_type을 포함하려고했습니다. 아무것도 효과가 없습니다.

Traceback (most recent call last): 
    File "<console>", line 1, in <module> 
AttributeError: 'SphinxSearch' object has no attribute 'query' 

아무도 대신 SphinxSearch를 사용하는 스핑크스

답변

6

에 여러 인덱스에서 내가 평가받을 수있는 방법 결과에 빛을 던질 수있는, 당신은 내가 세 가지를 조회하고자한다면, 예를 들어 SphinxQuerySet

사용하려면 title, tagscontent 필드를 사용하여 결과의 ​​무게를 측정하고 사용자 지정 일치 (SPH_MATCH_EXTENDED2) 및 순위 (SPH_RANK_NONE) 모드를 설정합니다.

from djangosphinx.models import SphinxQuerySet 

search = SphinxQuerySet(
    index = "index_1 index_2 index_n", 
    weights = { 
     'title': 100, 
     'tags': 80, 
     'content': 20 
    }, 
    mode = 'SPH_MATCH_EXTENDED2', 
    rankmode = 'SPH_RANK_NONE') 

results = search.query('what is the answer to life, the universe, and everything?') 

for result in results: 
    print result 
+3

대답은 42입니다. – nabizan