What is Multi-Values Field?
In the previous blog, we have created a new collection “films”, and it has several multi-values fields such as directed_by, genre and name. Let’s open the C:/{your_installed_path}/solr-5.4.1/server/solr/films/conf/managed-schema.xml to have a look:
However, these fields have not stated ‘multiValued=”true”’, how do you know they aremulti-values? You can check their field type, for example, genre’s field type is “strings”, and you can find the field type definition from managed-schema.xml file:
<fieldType name=”strings” class=”solr.StrField” multiValued=”true” sortMissingLast=”true”/>
And the field “name” field type is “text_general”, you can also find this definition from managed-schema.xml file as well:
<fieldType name=”text_general” class=”solr.TextField” multiValued=”true” positionIncrementGap=”100″>
<analyzer type=”index”>
<tokenizer class=”solr.StandardTokenizerFactory”/>
<filter class=”solr.StopFilterFactory” words=”stopwords.txt” ignoreCase=”true”/>
<filter class=”solr.LowerCaseFilterFactory”/>
</analyzer>
<analyzer type=”query”>
<tokenizer class=”solr.StandardTokenizerFactory”/>
<filter class=”solr.StopFilterFactory” words=”stopwords.txt” ignoreCase=”true”/>
<filter class=”solr.SynonymFilterFactory” expand=”true” synonyms=”synonyms.txt” ignoreCase=”true”/>
<filter class=”solr.LowerCaseFilterFactory”/>
</analyzer>
</fieldType>
So, they are multi-values fields. You can go to http://localhost:8983/solr/films/query?q=day and see what is different between multi-values and non multi-values field:
If the field is multi-values such as “genre”, it will return with square brackets and values separate by “|”. Otherwise, it will just return with double quote like the field “id”.
You can define your own field type(s) or add new field(s) by either:
a. updating managed-schema.xml file. Then, it will be effective after restart the SOLR by “solr restart –p 8983”:
b. curl http://localhost:8983/solr/films/config/params
c. or, using Postman to make a HTTP POST request
You can refer to the previous blog for methods b and c.