Search code examples
javasolrdatastaxdatastax-enterprise

DSE Solr : CopyField behavior


I have defined integer field in Solr schema.xml as below. <field indexed="true" multiValued="false" name="build_status" stored="true" type="TrieIntField"/> And copy Field defined as follows with boolean type.

<field name="build_status_b" stored="false" indexed="true" type="boolean" multiValued="false"/> <copyField dest="build_status_b" source="build_status"/>

I set build_status value which is integer with following values. 0, 1, 45, 67 Since my copyField - build_status_b of type boolean, I was expected to see either error or It will hold 0 and 1 and ignore 45 and 67 as these number does not come into boolean contract. But, interestingly I could able search build_status_b:(0 1 45 67) with all the values. How does copyFields really works and if it indexes whatever source field holds what is the point of declaring type for field build_status_b ?


Solution

  • If you look at the following doc link on the Solr wiki you'll see that the bool field type will interpret these values to form a boolean value:

    https://cwiki.apache.org/confluence/display/solr/Field+Types+Included+with+Solr

    Contains either true or false. Values of "1", "t", or "T" in the first character are interpreted as true. Any other values in the first character are interpreted as false.

    For reference heres the Solr docs for copyFields:

    https://cwiki.apache.org/confluence/display/solr/Copying+Fields

    So for your above values they will be representative of the stated boolean equivalents:

    0  - false
    1  - true
    45 - false
    67 - false