django haystack SearchField,索引为False

编程入门 行业动态 更新时间:2024-10-10 03:22:56
本文介绍了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/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 - django-haystack.readthedocs/en/latest/searchindex_api.html#stored-indexed-fields

更多推荐

django haystack SearchField,索引为False

本文发布于:2023-11-24 23:35:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1627365.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:索引   haystack   django   False   SearchField

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!