2

I'm trying to use an analyzer on my computed field to allow searching with spaces. Nothing I've tried works yet. Any ideas?

<contentSearch>
      <indexConfigurations>
          <defaultSolrIndexConfiguration type="Sitecore.ContentSearch.SolrProvider.SolrIndexConfiguration, Sitecore.ContentSearch.SolrProvider">
              <fieldMap type="Sitecore.ContentSearch.SolrProvider.SolrFieldMap, Sitecore.ContentSearch.SolrProvider">
                  <fieldNames hint="raw:AddFieldByFieldName">
                      <field fieldName="firstlastname" storageType="yes" indexType="tokenized" type="string">
                        <analyzer type="Sitecore.ContentSearch.SolrProvider.Analyzers.LowerCaseKeywordAnalyzer, Sitecore.ContentSearch.SolrProvider" />
                      </field>
                  </fieldNames>
              </fieldMap>
              <documentOptions type="Sitecore.ContentSearch.SolrProvider.SolrDocumentBuilderOptions, Sitecore.ContentSearch.SolrProvider">
                  <fields hint="raw:AddComputedIndexField">
                      <field fieldName="firstlastname" storageType="yes" indexType="tokenized"> Sitecore.Fields.FirstLastNameComputedField, Circle.Fields</field>
                  </fields>
              </documentOptions>
          </defaultSolrIndexConfiguration>
      </indexConfigurations>
  </contentSearch>

2 Answers 2

1

To have included spaces into your index at population you need to specify indexType="UNTOKENIZED", and then at the indexing the spaces are not removed.

If you want to use analyser, your current analyser removes spaces and converts them into lowercase. Example: Input: "I just LOVE my Phone!" Output: "i", "just", "love", "my", "phone"

Check other analyzer if you want spaces and use untokenized for computed index field:

<field fieldName="firstlastname" storageType="yes" indexType="UNTOKENIZED"> Sitecore.Fields.FirstLastNameComputedField, Circle.Fields</field>
                  </fields>

More details about tokenizers: https://solr.apache.org/guide/7_4/tokenizers.html

0

I'm not sure when it changed but in Sitecore 10.x you now need to change the returnType parameter which is used for whether the field gets tokenized or not. For example string does not get tokenized but text does.

<field fieldName="firstlastname" returnType="string"> Sitecore.Fields.FirstLastNameComputedField, Circle.Fields</field>
                  </fields>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.