I am a little confused as to what the behaviour of the index and stored attibutes of the Solr fields is.
For example if I have the following in the Schema.xml
<field name="test1" type="text" indexed="false"
stored="false" required="false" />
Will the field test1 be not stored in the Solr document even if I create a document with that field in it and set a value to that field and commit the document to Solr. As I have the stored=false
attribute, does it mean that the value of the field is lost in Solr and not persisted?
That is correct. Typically you will want your field to be either indexed or stored or both. If you set both to false, that field will not be available in your Solr docs (either for searching or for displaying). See Alexandre's answer for the special cases when you will want to set both to false.
As stated here : indexed=true
makes a field searchable (and sortable and facetable). For eg, if you have a field named test1
with indexed=true
, then you can search it like q=test1:foo
, where foo
is the value you are searching for. If indexed=false
for field test1
then that query will return no results, even if you have a document in Solr with test1
's value being foo
.
stored=true
means you can retrieve the field when you search. If you want to explicitly retrieve the value of a field in your query, you will use the fl
param in your query like fl=test1
(Default is fl=*
meaning retrieve all stored fields). Only if stored=true
for test1
, the value will be returned. Else it will not be returned.