2

I am writing some optimised search code which talks directly to Solr (uses HTTP requests and parses JSON responses). I am skipping the ContentSearch Sitecore API altogether. Some index fields are suffixed with _s of type string and shared (not specific versions per language). Some index fields are suffixed with _t of type text and are non-shared. When I browse the schema with the Solr admin tool, I see that the fields suffixed with _t have related fields e.g. where there is

__display_name_t

there are also corresponding fields

__display_name_t_en
__display_name_t_fr
__display_name_t_it

Can I simply take the Sitecore context language, e.g. en-GB take the first two characters "en" and then append them to the end of my field name (provided it has the _t suffix), or is the logic more complex than this?

Is there some good way to validate field names to avoid ending up with an invalid search query?

3

If you have a look at index configuration, you will find something similar to

<typeMatch 
  type="System.String" 
  typeName="text"
  fieldNameFormat="{0}_t"
  cultureFormat="_{1}"
  settingType="Sitecore.ContentSearch.SolrProvider.SolrSearchFieldConfiguration, Sitecore.ContentSearch.SolrProvider" />

That's line says that text is the only type which uses cultureFormat to create language specific versions of the fields in Solr documents.

When Sitecore adds documents to index or queries index, it checks that cultureFormat setting and uses it to include language information.

As far as I know, language information is generated using code similar to:

return 
  culture.Equals(CultureInfo.InvariantCulture) 
    ? string.Empty 
    : culture.TwoLetterISOLanguageName;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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