开发者

How to get field name

开发者 https://www.devze.com 2022-12-14 10:25 出处:网络
Recently i have implemented django-sphinx search on my website. It is working fine of each separate model.

Recently i have implemented django-sphinx search on my website. It is working fine of each separate model. But now my client requirement has changed. To implement that functionality i need field name to whom search is made.

suppose my query is: "select id, name,description from table1" and search keyword is matched with value in field "name". So i need to return that field also. Is it possible to get field name or any method provided by django-sphinx which return field na开发者_开发问答me.

Please help me...


As far as I know, this isn't possible. You might look at the contents of _sphinx though.


Well from django-sphinx it might not be possible. But there is a solution -

  1. Make different indexes, each index specifying the field that you need to search.
  2. In your django-sphinx models while searching do this -

search1 = SphinxSearch(index='index1')

search2 = SphinxSearch(index='index2')

...

After getting all the search results, you aggregate them & you have the info of from where they have come.

0

精彩评论

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