Azure Search Sitecore Custom Index

No comments

If you are looking to convert your Lucene or Solr custom indexes to Azure Search indexes – then this sample Azure search custom index configuration will help you to quickly alter them.

<configuration xmlns:patch="">
             This strategy is triggered on publish:end and uses the EventQueue to incrementally rebuild the index. The strategy contains all indexes which belong to it. 
            <onPublishEndAsyncSingleInstance type="Sitecore.ContentSearch.Maintenance.Strategies.OnPublishEndAsynchronousSingleInstanceStrategy, Sitecore.ContentSearch" singleInstance="true">
                <param desc="database">web</param>
                <!-- Whether or not a full index rebuild should be triggered when the number of items in the EventQueue exceeds the number specified 
               in ContentSearch.FullRebuildItemCountThreshold. -->

			<!-- Name of customIndex			-->
                < ref="contentSearch/indexConfigurations/defaultCloudIndexConfiguration" >

                    <!-- DEFAULT FIELD MAPPING
               The field map allows you to have full control over the way your data is stored in the index. This affects the way data is queried, 
               the performance of searching, and the way that data is retrieved and cast to a proper type in the API. 
                    <fieldMap ref="contentSearch/indexConfigurations/defaultCloudIndexConfiguration/fieldMap">
                        <fieldNames hint="raw:AddFieldByFieldName">
                            <field fieldName="_uniqueid"            storageType="YES" indexType="TOKENIZED"    vectorType="NO" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider">
                                <analyzer type="Sitecore.ContentSearch.LuceneProvider.Analyzers.LowerCaseKeywordAnalyzer, Sitecore.ContentSearch.LuceneProvider" />
                    <documentOptions type="Sitecore.ContentSearch.DocumentBuilderOptions, Sitecore.ContentSearch">

						NOTE: Azure Search can ONLY store upto 1000 Fields
						This flag will index all fields by default. This allows new fields in your templates to automatically be included into the index.
               You have two choices :                
               1) Set this to 'true' and place all the fields that you would like to remove in the 'ExcludeField' list.
               2) Set to false and place all fields you would like to be indexed in the 'IncludeField' list below.

                 This setting allows you to exclude items that are based on specific templates from the index.
                        <exclude hint="list:AddExcludedTemplate">

                        <!-- GLOBALLY INCLUDE TEMPLATES IN INDEX
                 This setting allows you to only include items that are based on specific templates in the index. You must specify all the
                 templates that you want to include, because template inheritance is not checked. 
                 When you enable this setting, all the items that are based on other templates are excluded, regardless of whether the template
                 is specified in the ExcludeTemplate list or not.
                        <include hint="list:AddIncludedTemplate">

                        <!-- COMPUTED INDEX FIELDS 
               This setting allows you to add fields to the index that contain values that are computed for the item that is being indexed.
               You can specify the storageType and indextype for each computed index field in the <fieldMap><fieldNames> section.
                        <fields hint="raw:AddComputedIndexField">
                            <field fieldName="TestComputedField" storageType="no" indexType="tokenized">Sc.Foundation.Search.TestComputedField,Sc.Foundation.Search</field>


			<configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
                <indexes hint="list:AddIndex">
				<!-- Note: Update the Index name below  -->
                    <index id="sample_azure_index" type="Sitecore.ContentSearch.Azure.CloudSearchProviderIndex, Sitecore.ContentSearch.Azure">
                        <param desc="name">$(id)</param>
                        <param desc="connectionStringName"></param>
                        <param desc="totalParallelServices">5</param>
                        <!-- This initializes index property store. Id has to be set to the index id -->
                        <param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />
                        <configuration ref="contentSearch/indexConfigurations/">
                            <scoringProfilesRepository ref="contentSearch/scoringProfilesRepository" />
                        <schemaBuilder ref="contentSearch/searchServiceSchemaBuilder" />
                        <searchService type="Sitecore.ContentSearch.Azure.Http.CompositeSearchService, Sitecore.ContentSearch.Azure" />
                        <strategies hint="list:AddStrategy">
                            <!-- NOTE: order of these is controls the execution order -->
                            <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/onPublishEndAsyncSingleInstance" />
                        <commitPolicyExecutor type="Sitecore.ContentSearch.CommitPolicyExecutor, Sitecore.ContentSearch">
                            <policies hint="list:AddCommitPolicy">
                                <policy type="Sitecore.ContentSearch.ModificationCountCommitPolicy, Sitecore.ContentSearch">
                        <locations hint="list:AddCrawler">
                            <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
								<!-- Note: Update the root path and Database based on Sitecore Instance Type  -->

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.