Azure Search - Sys_content field doesn't get returned

Jeroen Harpe asked on August 13, 2021 09:11

Hi,

I have created an Azure search index and trying to receive data from the sys_content field. I'm getting data returned from other fields but the sys_content field doesn't exist.

The indexed content exists of pages and only CMS.MenuItems as the page type. I have customized the CMS.Document class and ticked the Azure "content" and "searchable" tick boxes on the search fields tab. On the CMS.MenuItem page I also ticked these checkboxes for the MenuItemName.

I'm using the following search params in the search client:

var searchParams = new Microsoft.Azure.Search.Models.SearchParameters
            {
                QueryType = QueryType.Full,
                SearchFields = new List<string>
                {
                    "sys_content",
                    "documentpagedescription",
                    "documentpagetitle",
                    "documentname",
                    "documenttags",
                    "documentpagekeywords",
                },
                // paging params
                IncludeTotalResultCount = true,
                Skip = pageIndex * pageSize,
                Top = pageSize,
            };

I've tried different configurations but I can't seem to return anything in the sys_content field. This is done in Kentico 11. Am I missing something?

Thanks

Recent Answers


Dmitry Bastron answered on August 13, 2021 13:23

Hi Jeroen,

This is because by default sys_content field in Azure Search index created by Xperience is not "Retrievable". But you can customize it. Please read through this manual how to customize Azure Search indexes and fields. Basically, you'd need to hook into CreatingField > Before event and change retrievable flag to true if that's a sys_content field.

1 votesVote for this answer Mark as a Correct answer

Jeroen Harpe answered on August 16, 2021 03:52

Hi Dmitry,

Thanks for your reply.

I have customized the Azure search index and now it's returning the sys_content field. However I'm still having issues filtering the content that's in the field. I want to exclude the "DocumentWebParts" field from the sys_content.

The DocumentWebParts searchfield doesn't exist when using the param in the CreatingField > Before event. Do I have to modify this in a different event?

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on August 16, 2021 07:17

Hi Jeroen,

As far as I know (I haven't checked in myself tbh) you've got a couple of options here, please check out the documentation:

  • Selecting only HTML output indexes the full output of the page, including document web parts JSON
  • Selecting only Content fields should solve your problem, however the document may not contain the full HTML output

It's worth checking I suppose. Other than this, I'm not sure whether there are any other customization options to exclude this info.

0 votesVote for this answer Mark as a Correct answer

Jeroen Harpe answered on August 16, 2021 07:59

Hi Dimitry,

As far I'm aware, those two options don't exist on K11. I will try to find another workaround to filter that content out from the sys_content field.

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on August 16, 2021 11:29

Sorry, yes, they aren't. Completely missed the fact it's v11.

Then I don't think it is possible to turn off easily. Probably maybe worth creating a custom content field or cutting webparts content from the existing (check out this article, it may be helpful).

0 votesVote for this answer Mark as a Correct answer

Jeroen Harpe answered on August 17, 2021 02:22

Hi Dmitry,

I will do that! Thanks for your time and confirming my thoughts.

Cheers

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.