Developer forum

Forum » Development » Extending the Content Index

Extending the Content Index

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I have a project where I need a bit of optimization. We are using the Content Index for listing a lot of articles, but in the template, we are also using some methods for retrieving additional details about authors and categories. It seems that the current approach is not optimal in terms of performance, and I am considering extending the current Content index with the additional details that we are now processing in the template.

Before I spend to much time investigating this, I would like to know if it would be possible to add an author object to the index. This object should return a list of Authors and each Author should be another object with at least 2 properties: Name and ID.

Is this scenario feasible? Should I proceed on this path?

Thank you,

Adrian


Replies

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Adrian,

 

We made something similar (IndexBuilderExtender), but never related to the author. It also depends on what you store on the Author field in the Dynamic Article.

 

In terms of performance on the IndexBuilderExtender, there are a few ways to handle that so performance is not hindered. You could Lazy Load a list of users, use services, or even just query the DB once.

 

What is the current approach you have where you are feeling performance issues?

 

Best Regards,

Nuno Aguiar

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nuno,

The actual data structure is actually more complex. I have used Author just as an example. We have a lot of meta-information attached to the actual Article: Authors, Categories, Sections, Tags, Companies. And the Article Item is only storing the ID or an array of IDs. The actual data that needs to be displayed is in separate Items.

Right now we have some custom methods/helpers retrieving those details. Some are based on SQL some are based on the API ( GetItem method(s) ).

The list of articles is pretty extensive and the site has a lot of hits. That's why I am gearing toward the Index. I am just not sure if I can index complex objects.

Thank you,
Adrian

 
Kevin Steffer
Kevin Steffer
Reply

Hi Adrian, you are on the right path by using the index instead of the database.

But you have to flatten our your relational database structure so that you have all your data (that has to be shown) in your index on your article (index document).

Example:

Entity: Article
Fields: Id, Name, Text, Authors, Categories, Tags, Companies
Where Authors, Categories, Tags and Companies are related Item IDs

You index extender now has to get the proper values from your relations and index those values.
Says forexample that you need the AuthorName, AuthorEmail, CategoryName, TagName, CompanyName, CompnayUrl, CompanyPhone

Your Article index documents then have to look like this:
Fields: Id, Name, Text, AuthorName, AuthorEmail, CategoryName, TagName, CompanyName, CompanyUrl, CompanyPhone

In you index extender you then have to get those fields our of the relations and add them to the index document.

If you have multiple Authors 1:N relation you can separate them with comma and the index fields must be of type System.String[] and then you have to make sure that the position if the array matches consider this scenario:

AuthorNames: Arian Ursu, Kevin Steffer, Nuno Aguiar
AuthorEmails: au@example.com, ks@example.com, na@example.com

If then Kevin doesn't have an email you need to keep the positions.

AuthorNames: Arian Ursu, Kevin Steffer, Nuno Aguiar
AuthorEmails: au@example.com,-, na@example.com

Hope you get what I mean.

Bets regards
Kevin

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Kevin,

Thank you for the feedback.

The database structure is exactly as you have described it.

And your explanation just clarified how I will have to index the properties.

Thank you very much.

Adrian

 

You must be logged in to post in the forum