Is it possible to have both a string and text index field for the same single line text field? I have tried adding my field to the DefaultIndexConfiguration config but it just takes on or the other.
1 Answer
It depends on the return type we are setting for that field. It is possible to set one return type for a field.
If you want this to be added to index in both the text and string return types, create a new computed index field
and append in the patch with the required return type
.
For Creating Computed filed:
public class yourclass: AbstractComputedIndexField
{
public override object ComputeFieldValue(IIndexable indexable)
{
object obj= null;
//logic to fetch content of your field
return obj;
}
}
Patch file: patch file to be added along with the return type specified.
<fields hint="raw:AddComputedIndexField">
<field fieldName="specify field name" returnType = "specify return type">Yourclass, namespace</field>
</fields>
-
Not quite what I was hoping for. I was aiming actually to have two index fields for one sitecore field: for example. SC field Title having a SOLR string and text field: title_s and title_t– LalaCommented Sep 22, 2022 at 9:38
-
Based on your existing configuration Sc field Title will store with one return type in the solr index and for the next return type you can add computed field as stated above, which will add new field in solr with the other return type. Hope this is clear? Commented Sep 22, 2022 at 9:41