1

I'm using Sitecore 9 update 1 and SXA 1.7, I created a computed index field but it's not searchable, when I search by its value the item that has the index field don't return, I'm using SXA search box and search results components.

Here is the configuration :

 <fields hint="raw:AddComputedIndexField">
          <field fieldName="serviceStep" returnType="string">project_namespace,DllName</field>
4
  • Can you provide the Sitecore configuration used to define the the computed field?
    – TamerM
    Commented Dec 26, 2018 at 14:18
  • @TamerM I edited the question and added the configuration Commented Dec 26, 2018 at 14:44
  • Have you rebuilt the index? Have you verified that the index contains data in that field? Commented Dec 26, 2018 at 15:58
  • @DanSinclairyes I done this, still not searchable Commented Dec 30, 2018 at 10:51

3 Answers 3

0

You might need to append the computed field into _content field, Try changing the computed field name to the following:

<fields hint="raw:AddComputedIndexField">
          <field fieldName="_content" returnType="string">project_namespace,DllName</field>
1
  • I changed it then rebuilt the index, I checked the solr the data I want is stored normally in "_content" field , still not searchable yet. Commented Dec 30, 2018 at 10:45
0

I do not believe there is a way to include your custom field in the _content field. That field is used to process all text fields in the Sitecore database.

You can read more about the _conent field here. What class indexes the _content index field

I believe you are going to have to query your field along with the the Content field.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
    <sitecore>
        <contentSearch>
            <indexConfigurations>
                <defaultSolrIndexConfiguration type="Sitecore.ContentSearch.SolrProvider.SolrIndexConfiguration, Sitecore.ContentSearch.SolrProvider">
                    <documentOptions type="Sitecore.ContentSearch.SolrProvider.SolrDocumentBuilderOptions, Sitecore.ContentSearch.SolrProvider">
                        <fields hint="raw:AddComputedIndexField">
                            <field fieldName="serviceStep" returnType="string">project_namespace,DllName</field>
                        </fields>
                    </documentOptions>
                </defaultSolrIndexConfiguration>
            </indexConfigurations>
        </contentSearch>
    </sitecore>
</configuration>

Then add your field to your extension of Sitecore's SearchResultItem class.

namespace Sitecore.Foundation.Indexing.Models
{
    using System.Collections.Generic;
    using Sitecore.ContentSearch;
    using Sitecore.ContentSearch.SearchTypes;

    public class IndexedItem : SearchResultItem
    {
        [IndexField("serviceStep")]
        public string ServiceStep { get; set; }
    }
}

Then you query your new field.

using (var context = ContentSearchManager.GetIndex("sitecore_web_index").CreateSearchContext())
{
    var searchQuery = context.GetQueryable<IndexedItem>()
        .Where(x => x.ServiceStep == "My Search Text);

    var results = searchQuery.GetResults()
}
1
  • I did it like this still no results, do you think I also need to include the computed index field in the SOLR managed schema? I cant see the field in my solr document
    – Bgl86
    Commented Nov 13, 2020 at 17:06
0

The search functionality will look into the sxacontent solr field, so add it by overriding the aggregated content. Other computed fields can be used for filtering purpose.

Your Answer

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

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