Quantcast
Channel: DevNet Questions
Viewing all articles
Browse latest Browse all 8901

Smart Search Index | Progammatically add fields

$
0
0
Using the information on https://docs.xperience.io/k12sp/configuring-kentico/setting-up-search-on-your-website/customizing-the-content-of-search-indexes I am able to append content of an indexed item.I was wondering if it is possible to programmatically add fields to a search index. For example, I would like to add DocumentPageTitle, DocumentPageDescription and DocumentPageKeyWords to a Smart Search Pages index. I've tried the following examplesprivate void GetContent_Execute(object sender, DocumentSearchEventArgs e) { TreeNode indexedPage = e.Node; if (indexedPage == null) return; // doesn't appear in the index e.SearchDocument.Add(@documentpagetitle@, indexedPage.DocumentPageTitle, true, false); // doesn't appear in the index var pageTitle = new SearchField { FieldName = @documentpagetitle@, Value = indexedPage.DocumentPageTitle }; e.SearchDocument.AddSearchField(pageTitle); } Version Kentico 12 SP MVC

Viewing all articles
Browse latest Browse all 8901

Trending Articles