Вопрос

In v1.4, If I define a field in Solr schema:

   <field name="MTID" type="string" />

this field will be single valued. Whereas in v3.5, it defaults to multi vaued. What's the cause? Does the Solr project make this decision?

I am about to jump into Solr 4 or 5, does this phenomena still exist?

note: I'm currently using Solr 3.5 on Tomcat 6.0 under Win7.

Это было полезно?

Решение

Using completely identical configuration files in two different versions of Solr will produce the same default behavior for schema attributes such as multiValued. If you are seeing different behavior, then you have a descrepency somewhere...

1) The default behavior of attributes on <field/> declarations is first and foremost determined by the attributes on the corresponding <fieldType/>. Since your question didn't specify what the <fieldType/> declaration for string is in both schema.xml files, it's possible that they differ between your two configs.

2) If there is no multiValued attribute defined on either the <field/> or <fieldType/> definition, then the default behavior comes from the class attribute specified by the <fieldType/> (eg: solr.StrField)

3) For built in Solr field types (eg: solr.StrField) the default behavior is entirely driven by the version attribute of the schema.xml. As detailed in the example schema.xml that ships with Solr...

<schema name="example" version="1.5">
  <!-- attribute "name" is the name of this schema and is only used for display purposes.
       version="x.y" is Solr's version number for the schema syntax and 
       semantics.  It should not normally be changed by applications.

       1.0: multiValued attribute did not exist, all fields are multiValued 
            by nature
       1.1: multiValued attribute introduced, false by default 
       1.2: omitTermFreqAndPositions attribute introduced, true by default 
            except for text fields.
       1.3: removed optional field compress feature
       1.4: autoGeneratePhraseQueries attribute introduced to drive QueryParser
            behavior when a single string produces multiple tokens.  Defaults 
            to off for version >= 1.4
       1.5: omitNorms defaults to true for primitive field types 
            (int, float, boolean, string...)
     -->

...so if the <field/> and <fieldType/> declarations in your configs are identical, the last thing to check is if you have modified the value of the version attribute on your <schema/> root element.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top