django haystack SearchField with indexed False

吃可爱长大的小学妹 提交于 2019-12-08 20:53:26

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/13616766/django-haystack-searchfield-with-indexed-false

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!