0

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>
  • Can you provide the Sitecore configuration used to define the the computed field? – TamerM Dec 26 '18 at 14:18
  • @TamerM I edited the question and added the configuration – Mohamed Mosa Dec 26 '18 at 14:44
  • Have you rebuilt the index? Have you verified that the index contains data in that field? – Dan Sinclair Dec 26 '18 at 15:58
  • @DanSinclairyes I done this, still not searchable – Mohamed Mosa Dec 30 '18 at 10:51
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>
  • 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. – Mohamed Mosa Dec 30 '18 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()
}

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.