Indexing of related content

Created by Webnodes

Very often when doing search templates in a project, you want to index the textual content of related nodes inside another node.


A common and recommended scenario is that you model your data around the natural data structure, and not the page structure. This increases the life span of the content.

The natural modeling of the content introduces a couple of situations that might be confusing to those never having used a CMS with strong support for relations between content.

One of those issues is that very often only some of the content classes have a template and url of their own. In Webnodes, one template is very often generated from the content of not just the one node having the specified url, but also content that the node relates to.  


In those situations, you want the search results to show a link to the node with the url and template, that includes the content from the related node, rather than the related node itself. For that to happen, you must instruct Webnodes to index the content of related nodes.

To enable indexing of related content, you must turn on a setting that only exists on a relation property: “Index content of related”. Make sure that the “Include in public index” setting is enabled and checked.


Indexing of content not directly related

If you need to include content from nodes that are not directly related, you must override the BuildSearchIndex method. One example of this is on an order, you might want it to include the product names and description in the order index. This makes it possible to search for a product name, the get results that includes the orders that contain that product.

Order and Product are not directly related. Order -> OrderItem -> Product. In those situations, you must add the content from Product to the Order search index manually in BuildSearchIndex.