Skip to main content
added 346 characters in body
Source Link
Chris Sulham
  • 1.5k
  • 11
  • 22

I think what you may need is a new field type. The _sm field is a string field in the Solr schema.xml, specifically a multivalued string field. There's no tokenizer specified, so I believe that means it uses the default tokenizer. What you want is the KeywordTokenizerFactory. The KeywordTokenizerFactory treats the entire value as a literal, so it includes spaces when matching. It's also case sensitive, but you can add a LowerCaseFilterFactory if that's an issue.

<fields>
...

    <dynamicField name="*_sm" type="string" indexed="true" stored="true" multiValued="true" />
    <dynamicField name="*_smnt" type="string_untokenized" indexed="true" stored="true" multiValued="true" />
...
</fields>
...
 <types>
...
    <fieldType name="string" class="solr.StrField" sortMissingLast="true" />
    <fieldType name="string_untokenized" class="solr.TextField" sortMissingLast="true" >
        <analyzer>
            <tokenizer class="solr.KeywordTokenizerFactory"/>
        </analyzer>
    </fieldType>
...
<types>
<fields>
    ...    
        <dynamicField name="*_sm" type="string" indexed="true" stored="true" multiValued="true" />
        <dynamicField name="*_smnt" type="string_untokenized" indexed="true" stored="true" multiValued="true" />
    ...
</fields>
...
<types>
    ...
    <fieldType name="string" class="solr.StrField" sortMissingLast="true" />
    <fieldType name="string_untokenized" class="solr.TextField" sortMissingLast="true" >
        <analyzer>
            <tokenizer class="solr.KeywordTokenizerFactory"/>
            <filter class="solr.LowerCaseFilterFactory"/>
        </analyzer>
    </fieldType>
    ...
<types>
<fieldMap type="Sitecore.ContentSearch.SolrProvider.SolrFieldMap, Sitecore.ContentSearch.SolrProvider">
    <!-- This element must be first -->
    <typeMatches hint="raw:AddTypeMatch">
        <typeMatch typeName="string_multi_untokenized"  type="System.String"  fieldNameFormat="{0}_smnt"  settingType="Sitecore.ContentSearch.SolrProvider.SolrSearchFieldConfiguration, Sitecore.ContentSearch.SolrProvider" />
    </typeMatches>
    <!-- This allows you to map a field name in Sitecore to the index and store it in the appropriate way -->
    <!-- Add schema fields here to enable multi-language processing -->
    <fieldNames hint="raw:AddFieldByFieldName">
        <field fieldName="read_roles"     returnType="string_multi_untokenized" />
    </fieldNames>
</fieldMap>
<fieldMap type="Sitecore.ContentSearch.SolrProvider.SolrFieldMap, Sitecore.ContentSearch.SolrProvider">
    <!-- This element must be first -->
    <typeMatches hint="raw:AddTypeMatch">
        <typeMatch typeName="string_multi_untokenized"  type="System.String"  fieldNameFormat="{0}_smnt"  settingType="Sitecore.ContentSearch.SolrProvider.SolrSearchFieldConfiguration, Sitecore.ContentSearch.SolrProvider" />
    </typeMatches>
    <!-- This allows you to map a field name in Sitecore to the index and store it in the appropriate way -->
    <fieldNames hint="raw:AddFieldByFieldName">
        <field fieldName="read_roles"     returnType="string_multi_untokenized" />
    </fieldNames>
</fieldMap>

I think what you may need is a new field type. The _sm field is a string field in the Solr schema.xml, specifically a multivalued string field. There's no tokenizer specified, so I believe that means it uses the default tokenizer. What you want is the KeywordTokenizerFactory.

<fields>
...

    <dynamicField name="*_sm" type="string" indexed="true" stored="true" multiValued="true" />
    <dynamicField name="*_smnt" type="string_untokenized" indexed="true" stored="true" multiValued="true" />
...
</fields>
...
 <types>
...
    <fieldType name="string" class="solr.StrField" sortMissingLast="true" />
    <fieldType name="string_untokenized" class="solr.TextField" sortMissingLast="true" >
        <analyzer>
            <tokenizer class="solr.KeywordTokenizerFactory"/>
        </analyzer>
    </fieldType>
...
<types>
<fieldMap type="Sitecore.ContentSearch.SolrProvider.SolrFieldMap, Sitecore.ContentSearch.SolrProvider">
    <!-- This element must be first -->
    <typeMatches hint="raw:AddTypeMatch">
        <typeMatch typeName="string_multi_untokenized"  type="System.String"  fieldNameFormat="{0}_smnt"  settingType="Sitecore.ContentSearch.SolrProvider.SolrSearchFieldConfiguration, Sitecore.ContentSearch.SolrProvider" />
    </typeMatches>
    <!-- This allows you to map a field name in Sitecore to the index and store it in the appropriate way -->
    <!-- Add schema fields here to enable multi-language processing -->
    <fieldNames hint="raw:AddFieldByFieldName">
        <field fieldName="read_roles"     returnType="string_multi_untokenized" />
    </fieldNames>
</fieldMap>

I think what you may need is a new field type. The _sm field is a string field in the Solr schema.xml, specifically a multivalued string field. There's no tokenizer specified, so I believe that means it uses the default tokenizer. What you want is the KeywordTokenizerFactory. The KeywordTokenizerFactory treats the entire value as a literal, so it includes spaces when matching. It's also case sensitive, but you can add a LowerCaseFilterFactory if that's an issue.

<fields>
    ...    
        <dynamicField name="*_sm" type="string" indexed="true" stored="true" multiValued="true" />
        <dynamicField name="*_smnt" type="string_untokenized" indexed="true" stored="true" multiValued="true" />
    ...
</fields>
...
<types>
    ...
    <fieldType name="string" class="solr.StrField" sortMissingLast="true" />
    <fieldType name="string_untokenized" class="solr.TextField" sortMissingLast="true" >
        <analyzer>
            <tokenizer class="solr.KeywordTokenizerFactory"/>
            <filter class="solr.LowerCaseFilterFactory"/>
        </analyzer>
    </fieldType>
    ...
<types>
<fieldMap type="Sitecore.ContentSearch.SolrProvider.SolrFieldMap, Sitecore.ContentSearch.SolrProvider">
    <!-- This element must be first -->
    <typeMatches hint="raw:AddTypeMatch">
        <typeMatch typeName="string_multi_untokenized"  type="System.String"  fieldNameFormat="{0}_smnt"  settingType="Sitecore.ContentSearch.SolrProvider.SolrSearchFieldConfiguration, Sitecore.ContentSearch.SolrProvider" />
    </typeMatches>
    <!-- This allows you to map a field name in Sitecore to the index and store it in the appropriate way -->
    <fieldNames hint="raw:AddFieldByFieldName">
        <field fieldName="read_roles"     returnType="string_multi_untokenized" />
    </fieldNames>
</fieldMap>
Source Link
Chris Sulham
  • 1.5k
  • 11
  • 22

I think what you may need is a new field type. The _sm field is a string field in the Solr schema.xml, specifically a multivalued string field. There's no tokenizer specified, so I believe that means it uses the default tokenizer. What you want is the KeywordTokenizerFactory.

Try this in the schema.xml,

<fields>
...

    <dynamicField name="*_sm" type="string" indexed="true" stored="true" multiValued="true" />
    <dynamicField name="*_smnt" type="string_untokenized" indexed="true" stored="true" multiValued="true" />
...
</fields>
...
 <types>
...
    <fieldType name="string" class="solr.StrField" sortMissingLast="true" />
    <fieldType name="string_untokenized" class="solr.TextField" sortMissingLast="true" >
        <analyzer>
            <tokenizer class="solr.KeywordTokenizerFactory"/>
        </analyzer>
    </fieldType>
...
<types>

Then in your Sitecore Solr config you need to add this field type, like so

<fieldMap type="Sitecore.ContentSearch.SolrProvider.SolrFieldMap, Sitecore.ContentSearch.SolrProvider">
    <!-- This element must be first -->
    <typeMatches hint="raw:AddTypeMatch">
        <typeMatch typeName="string_multi_untokenized"  type="System.String"  fieldNameFormat="{0}_smnt"  settingType="Sitecore.ContentSearch.SolrProvider.SolrSearchFieldConfiguration, Sitecore.ContentSearch.SolrProvider" />
    </typeMatches>
    <!-- This allows you to map a field name in Sitecore to the index and store it in the appropriate way -->
    <!-- Add schema fields here to enable multi-language processing -->
    <fieldNames hint="raw:AddFieldByFieldName">
        <field fieldName="read_roles"     returnType="string_multi_untokenized" />
    </fieldNames>
</fieldMap>