开发者

how to obtain two different search results from single query in django haystack with solr

I have one search box where users can search for either the movie name or actor. On the search results page I want to show the top hits for both the actor and for the movie name in separate tables. How is this done with Django开发者_如何学Go Haystack over SOLR?

Thanks!


This post is old but I stumbled over it because I wanted to do the same thing. Like Mauricio Scheffler said you have to make two queries. In haystack you can specify witch model is queried:

query1 = SearchQuerySet().filter(content="something").models(Actor)
query2 = SearchQuerySet().filter(content="something").models(Movies)

If both values are in one table or the tables are related. You can place the results you want in the template.

{{ movies.object.actor }}
{{ movies.object.name }}


Don't know about haystack, but from a Solr point of view you'll have to run one query for actors and another query for movies.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜