简体   繁体   English

Django Sphinx文字搜寻

[英]Django Sphinx Text Search

I am trying out Sphinx search in my Django project. 我正在Django项目中尝试Sphinx搜索。 All setup done & it works but need some clarification from someone who has actually used this setup. 所有设置均已完成且可以使用,但需要实际使用此设置的人进行说明。

In my Sphinx search while indexing, I have used 'name' as the field in my MySQL to be searchable & all other fields in sql_query to be as attributes (according to Sphinx lingo). 在索引时的Sphinx搜索中,我已经将“名称”用作MySQL中的可搜索字段,并将sql_query中的所有其他字段用作属性(根据Sphinx术语)。

So when I search from my Model instance in Django, I get the search results alright but it does not have the 'name' field in the search results. 因此,当我从Django中的Model实例搜索时,我得到的搜索结果还不错,但搜索结果中没有'name'字段。 I get all the other attributes. 我得到所有其他属性。

However, I get the 'id' of the search term. 但是,我得到了搜索词的“ id”。 Technically, I could get the 'name' by again querying MySQL but I want to avoid this. 从技术上讲,我可以通过再次查询MySQL来获取“名称”,但我想避免这种情况。 Is there anything I am not doing here? 我在这里没有做什么吗?

Here's a shot in the dark - 这是黑暗中的一枪-

Try to get the name of your index in sphinx.conf same as the table_name you are trying to index. 尝试在sphinx.conf中获得与要建立indextable_name相同的索引名称。 This is a quirk which is missed by lot of people. 这是很多人都错过的怪癖。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM