Adding a multivalued, commas separated String to S

2019-08-04 03:02发布

问题:

I am trying to add a multivalued content to Solr index. The original String contains values seperated by ",".

<fieldtype name="commas_type" class="solr.TextField" omitNorms="true">
    <analyzer type="index">
        <tokenizer class="solr.PatternTokenizerFactory" pattern=",\s*"/>
        <filter class="solr.LowerCaseFilterFactory" />
    </analyzer>
    <analyzer type="query">
        <tokenizer class="solr.PatternTokenizerFactory" pattern=",\s*"/>
        <filter class="solr.LowerCaseFilterFactory" />
    </analyzer>
</fieldtype> 


<field name="keywords" type="commas_type" stored="true" indexed="true" multiValued="true" />

But instead of getting :

 <doc>
   <arr name="keywords">
     <str>Agile</str>
     <str>Kanban</str>
     <str>Clojure</str>
     <str>Datomic</str>
   </arr>
 </doc>

I'm getting:

 <doc>
   <arr name="keywords">
     <str>Agile, Kanban</str>
     <str>Clojure, Datomic</str>
   </arr>
 </doc>

回答1:

Solr does not change the Stored values for the Original data.
The pattern tokenizer would only be applied to the index values. So if you check your index for the indexed terms you would get the values splitted by ,.
However, the values returned by Solr would always be the values fed to it.

You would need to handle it at client side.



标签: java solr