django haystack SearchField,索引为False [英] django haystack SearchField with indexed False

查看:139
本文介绍了django haystack SearchField,索引为False的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有理由将 indexed = False 其他字段设置为 SearchIndex



文档提到,应该为过滤或排序结果定义附加字段。默认情况下 SearchIndex 具有 indexed = True ,所以如果我设置 indexed = False / code>?



数据是否仍然存储在索引上,但不能编入索引?如果我设置 stored = False 会发生什么?



它是如何工作的?



谢谢

解决方案

默认情况下,干草堆中的所有字段均被索引(由引擎搜索)并存储(由引擎保留并显示在结果中)。通过使用存储的字段,可以存储常用的数据,以便在处理搜索结果以获取更多信息时不需要打数据库。如果您指定 indexed = True stored = True ,则可获得此优势。



如果您只指定 indexed = True ,则在处理搜索结果以获得额外的数据时,您将会击中数据库信息在索引中不可用。



indexed = False 的目的是为了满足您想要的场景在索引过程中,渲染字段遵循预渲染的模板。这里举例说明一个很好的例子 - https:// django- haystack.readthedocs.org/en/latest/searchindex_api.html#stored-indexed-fields


Is there any reason to set additional fields with indexed=False into SearchIndex?

Documentation mentioned that additional fields should be defined for filtering or ordering results. By default SearchIndex has indexed=True, so what happens if I set indexed=False?

Will the data still be stored on index but not be indexed? What happens if I'd set stored=False?

How does it works?

Thanks

解决方案

By default, all fields in Haystack are both indexed (searchable by the engine) and stored (retained by the engine and presented in the results). By using a stored field, you can store commonly used data in such a way that you don’t need to hit the database when processing the search result to get more information. You get this advantage if you specify indexed=True and stored=True.

If you specify only indexed=True, you will be hitting the database when processing the search result to get additional information not available in the index.

The purpose of indexed=False is to cater for the scenario where you want a rendered field to follow a pre-rendered template during the indexing process. A good example is illustrated here - https://django-haystack.readthedocs.org/en/latest/searchindex_api.html#stored-indexed-fields

这篇关于django haystack SearchField,索引为False的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆