2

I need to add custom field to Azure search schema and set up copy field rules to get the values of some other fields and set them as the values of this custom field. I can do it in Solr with Schema API, but is it possible to do the same with Azure Search?

Examples of what I do with Solr Schema API shown below:

Create custom type:

{
"add-field-type":{
    "name":"custom_text_type",
    "class":"solr.TextField",
    "positionIncrementGap":"100",
    "indexAnalyzer":{
        "type":"index",
        "tokenizer":{
            "class":"solr.StandardTokenizerFactory"
        },
        "filters":[
            {
                "class":"solr.StopFilterFactory",
                "ignoreCase":"true",
                "words":"stopwords.txt"
            },
            {
                "class":"solr.LowerCaseFilterFactory"
            }
        ]
    },
    "queryAnalyzer":{
        "tokenizer":{
            "class":"solr.StandardTokenizerFactory"
        },
        "filters":[
            {
                "class":"solr.StopFilterFactory",
                "ignoreCase":"true",
                "words":"stopwords.txt"
            },
            {
                "class":"solr.SynonymFilterFactory",
                "synonyms":"synonyms.txt",
                "ignoreCase":"true",
                "expand":"true" 
            },
            {
                "class":"solr.LowerCaseFilterFactory"
            }
        ]
    }
}

Create custom field:

{
"add-field":{
 "name":"custom_field",
 "type":"custom_text_type",
 "indexed":true,
 "stored":true,
 "multiValued":true
}}

Finally, add some copy field rules

{
  "add-copy-field":[
  {
   "source":"teaser_t",
   "dest":"custom_field"
  },
  {
   "source":"global_search_keywords_t",
   "dest":"custom_field"
  }
]}
0

The Azure Search schema is completely managed by Sitecore, so even if there was a way to do this purely via schema changes I wouldn't recommend it as it would not be easily scalable, especially if you're using the index switch on rebuild functionality.

Instead I think you have two options:

or

  • Use the sitecore index with a custom SearchResultItem and map those fields to the property manually. (e.g. on the property getter you can check the Fields collection for teaser_t and global_search_keywords_t.)

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.