Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django haystack SearchField with indexed False

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

like image 627
Fibio Avatar asked Nov 29 '12 00:11

Fibio


1 Answers

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

like image 114
Calvin Cheng Avatar answered Nov 04 '22 20:11

Calvin Cheng