Developer forum

Forum » Development » New indexing documentation

New indexing documentation

Peter Leleulya
Reply

Hi there,

Can anyone tell me where to find the documentation on how to use the searching framework introduced with DW8.6?
Looking at the other forum threads you guys seem to be using it.
I've seen the presentations at DWTC15 and also at the DW head office, but unfortunately that doesn't mean I know it by heart.
Preforably I would like to build indexes programmatically (because we create shops and attached sites programmatically) and query them for products and search output.
Searching the documentation online only seem to serve me index search info from 2010.


Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
This post has been marked as an answer

Hi Peter,

You can find the preliminary documentation here: http://developer.dynamicweb.com/downloads/documentation.aspx

Under the section Dynamicweb, find the document about Indexing.

- Jeppe

EDIT

The documentation does not deal with the APIs or anything related to coding against them.

Votes for this answer: 1
 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

In order to start a build from code, you need to invoke the BuildIndex method in the current IndexService. You need to specify the repository, index definition, instance and build to use.

Something like this:

 

using Dynamicweb.Extensibility;
using Dynamicweb.Indexing;

namespace BuildStarter
{
    public class BuildStarter
    {
        public void StartBuild()
        {
            // Assume I have a repository called 'Ecommerce'
            // This repository has an index definition file called 'Products.index'
            // The index definition has an instance called 'Instance A'
            // The index definition also has a build definition called 'Full build'

            // The name of the repository (folder name)
            var repositoryName = "Ecommerce";
            // The index name (file name)
            var indexName = "Products.index";
            // The name of the build
            var build = "Full build";
            // The name of the instance
            var instance = "Instance A";

            // Get the current IIndexService from the ServiceLocator
            var indexService = ServiceLocator.Current.GetInstance< IIndexService >();
            // Build the specified index using the IIndexService
            indexService.BuildIndex(repositoryName, indexName, instance, build);
        }
    }
}

You also need assembly references to Dynamicweb.Indexing and Dynamicweb.Extensibility.

- Jeppe

 
Peter Leleulya
Reply

Thanks for the head start, we'll try to figure it out ...

 
Lars Larsen
Reply

Hi

I have implemented your code Jeppe and it's running without errors. After it has runned I check the status of the index in "MC - Repositories". Here it say's: "The given key was not present in the dictionary." and the index is not rebuilded. What can be wrong?

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Can you check the log file and post the stack trace? You can find the log file for the different builds in the /Files/System/Diagnostics/<Repository>/<Index>/<Instance> folder. Find the folder that corresponds to the time you ran the update and check the Status.xml file.

- Jeppe

 
Lars Larsen
Reply

Hi Jeppe

Here are output from the two logs:

Files\System\Diagnostics\Products\Products.index\Lucene\2015-06-30 135156\Status.xml:

<?xml version="1.0" encoding="UTF-8" standalone="true"?>

-<Status>

<StartTime Humanized="2015-06-30 13:51:56" Ticks="635712691164925303"/>

<EndTime Humanized="2015-06-30 13:51:56" Ticks="635712691165335392"/>

<RunTime>42</RunTime>

<Count>0</Count>

<TotalCount>0</TotalCount>

<State>Failed</State>


-<Fail>

<Reason>BuildIndex failed.</Reason>

<ExceptionMessage>The given key was not present in the dictionary.</ExceptionMessage>

<ExceptionStackTrace> at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at Dynamicweb.Indexing.IndexService.<>c__DisplayClass1.<BuildIndex>b__0(Tracker tracker)</ExceptionStackTrace>

</Fail>

<LogInformation>Failed.</LogInformation>

<Meta/>

</Status>

 

Files\System\Diagnostics\Products\Products.index\Lucene\2015-06-30 135156\Log.log:
2015-06-30 13:51:56.4965|INFO|Dynamicweb.Diagnostics.Tracking.Tracker|Running.
2015-06-30 13:51:56.5315|FATAL|Dynamicweb.Diagnostics.Tracking.Tracker|BuildIndex failed.
2015-06-30 13:51:56.5315|INFO|Dynamicweb.Diagnostics.Tracking.Tracker|Failed.

 

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

It seems that the build, you're referencing doesn't exist for the index you've specified. The build is the name of the build nad it must be written exactly as it appears in the UI / XML.

Consider this setup:

Here the indexName is 'Products.index' and the buildName is 'Full build'. Spaces, casing and special characters are all important.

 
Lars Larsen
Reply

Arh... your'e right. The problem was wrong name for the build. My build is called "Full". Changed the name and now it works. Thanks.

 
Jan Schultz
Reply

I think i remember someone said that if there are multiple instances on an index, the indexing engine will use the first index that has been succesfully build (Very good as fall-back strategy).

 

But if i have multiple instances on an index, how do i check if a build was successful when building an index using the code provided above? The BuildIndex called from the IIndexService triggers a task, so i guess we have to use the Tracker somehow?

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Jan,

There are a couple of different approaches, depending on whether or not you want information about a running task.

While there are no helper methods to get the information directly, you can get at it using this code. I'll look into adding a helper method to 8.7.

using Dynamicweb.Diagnostics.Tasks;
using Dynamicweb.Diagnostics.Tracking;

using System.Linq;
using System.IO;

namespace Indexing
{
    public class BuildInfo
    {
        public static bool IsLatestBuildSuccessful(string repositoryName, string indexName, string instanceName)
        {
            // Get path to task folder for the build
            var taskPath = Path.Combine(TaskManager.BaseFolder, repositoryName, indexName, instanceName);
            // Get taskName for the build task
            var taskName = string.Format("{0}#{1}#{2}", repositoryName, indexName, instanceName);

            Status latestStatus = null;

            // If the build is done, return the status from the list 
            // Else return the status from the active task
            if (TaskManager.IsTaskActive(taskName))
            {
                // Get TaskInfo for the running task
                var taskInfo = TaskManager.GetTaskInfo(taskName);
                if (taskInfo.HasValue)
                {
                    // Get Tracker from the TaskInfo
                    var tracker = taskInfo.Value.Tracker;
                    // Get the Status object from the Tracker
                    latestStatus = tracker.Status;
                }
            }
            else
            {
                // Get the latest Status object for the task from disk
                // The '1' specifies how many Status objects to get
                var statusList = Tracker.GetStatusHistory(taskPath, 1);
                // Get the first Status object in the list
                latestStatus = statusList.FirstOrDefault();
            }

            // If no Status was found, the Instance was never built:    return value is false
            // If the task is still running, the State is Running:      return value is false
            // If the task failed, the State is Failed:                 return value is false
            // If Status exists and State is Completed:                 return value is true
            return latestStatus != null && latestStatus.State == TrackingState.Completed;
        }
    }
}

This requires an assembly reference to Dynamicweb.Diagnostics.dll.

You can also change the code to loop through all instances on an IIndex and you can choose to not look at the active task if you're only interested in the final outcome of the task.

- Jeppe

 
Adrian Ursu
Reply

Hello Guys,

Is there any "New Indexing for Dummies" documentation that can help me replace the current Product Index with the new one?

I have tried with the draft documentation that is posted on Developer site but I couldn't list anything.

I believe there are a bunch of other guys that are not programmers that would want to be able to switch to the new Indexing.

I donlt need a "tweaked" version of the idex but one that can replace the default indexing.

Maybe it would be an ideea to include the default settings in the empty database/application files.

Thanks,

Adrian

 
Adrian Ursu
Reply

Hello Guys,

Disregard my previous post.

I could find the instructions in Jeppe's webinar videos.Many thanks for the instructions.

@Jeppe: can you point me to a place on github where I can download the FacetsTemplate from?

Thanks,

Adrian

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Adrian,

I've added the templates to the dwtc15 repo on GitHub. You can get them here: https://github.com/dynamicweb/dwtc15/

- Jeppe

 
Adrian Ursu
Reply

Thanks a lot.

I have played a bit with the new index functionality and I have some additional questions and comments:

1. How should I deal with translations of the Parameter Names? Right now, I can go in ManagementCenter/Ecommerce/ProductCatalog/SearchFilter/<SearchFilter>/<SearchField> and change the name of the field for each language that I am using in the shop. I don't see how to do this with the new index

2. For the cases where the ProductCatalog Module should display products from a set of ProductGroups it's nearly impossible to use the new index and still give the admin control over what they want displayed. because GroupID is either hardcoded (Constant) or taken from the EcomNavigation (Macro) the Admin cannot control what the product catalog displays unless changing the Query for the Index (or creating a new query and a new Facet). Have you considered keeping the ProductGroup Selector in the ProductCatalog UI and get the Macro value of the GroupID[] from there? Maybe a new category of options for Macro? ModuleSettings or something like that?

Thank you very much,
Adrian 

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Adrian,

1) The new indexing is completely Ecommerce agnostic, therefore, it's not possible to use languages inside the the module. This is where the new translation system comes into play. Create a set of keys that you can link to the facets in some way and translate them into the languages you have in your fontend. Then use the @Translate tag in your template to get the translated value.

2) We're introducing a new feature in Dynamicweb 8.8 where you can change the default values for parameters on the paragraph module. This gives you the option to specify which groups to use for that paragraph. While it's not as nice as having a group selector, it does solve the issue.

- Jeppe

 
Adrian Ursu
Reply

1. Got it. I think this might solve it.

2. If by default values you mean changing or adding the GROUP ID, it's not friendly at all. You should keep in mind that Administrators want to make changes easy and fast. That's where UI/UX makes a lot of difference. And for those that are already used to the existing interface, it will be even harder.

As a general comment, the whole world of CMS/Ecommerce goes toward the Visual editing path rather than parameter/code/tag path. You might want to consider it in UI decisions.

Thank you,
Adrian

 
Adrian Ursu
Reply

Hi Jeppe, 

One more thing.

How do I handle sorting in the product list with the new index?

SortBy=Name&SortOrder=DESC does not seem to work.

Unless I did something wrong in configuring the Index.

 
Nicolai Høeg Pedersen
Reply

Hi Adrian

Take a look at this thread: http://developer.dynamicweb.com/forum.aspx?PID=48&ThreadID=42556

BR Nicolai

 
Adrian Ursu
Reply

Got it. Makes sense.

All in all, the new indexing is very powerful.

If you manage to fix some UI control on the Groups that can be included in a ProductCatalog module, I think it can easily replace the current way of indexing.

And a bit more comprehensive documentation. The existing documentation, without Jeppe's webinars (kudos Jeppe) is almost useless.

Thanks,

Adrian

 
Nicolai Høeg Pedersen
Reply

Hi Adrian

I agree on the group selector thing - this indexing engine is indexing everything in Dynamicweb though and therefore is not bound to the ecommerce system it self. But we are working on a solution to that issue.

Despite that missing link, this engine is by far the old search engine superior. It can do so many things so much faster that using the 'old' one is asking for trouble :-).

BR Nicolai

 
Adrian Ursu
Reply

Yes. You have a lot more control over it and it's damn fast :)

I was thinking if you still take some settings from the ProductCatalog module why not leaving the Group Selector interface in place for selecting the Groups and then Filter the Index based oin that list of ID's. Similar with what you are doing when taking the GroupID from EcomNavigation.
It's an already familiar interface and prevent you from having to create separate Queries just to be able to display some groups.

In MBT's case, I could not use the Ecom NAvigation and I had to create separate page for each Group. This means that each Product Catalog has it's own list of groups.

In this case I had to create a Query for each product group Men, Women, Men Dress, Men Casual, Men Sport, Women Dress, Women Casual, Women Sport, New Arrivals.

And they have only 20 shops.

I agree I can copy/paste definitions but imagine what it means to have to add or change a parameter in all queries :)

If I could have used the same query and filter by product groups in the ProductCatalog module, it would have been much easier.

Thanks,
Adrian

 
Nicolai Høeg Pedersen
Reply

Hi Adrian

In 8.8 you can override the parameters on the paragraph directly.

We cannot keep the group selector for technical reasons. We have no clue how your search is configured, so we cannot match that information with your query parameter. But we will solve it.

If you have to create a page for each group, I'm pretty sure the implementation could be made in a better way. I've not yet seen a reasonable explation of why this is needed... My 2 cents.

BR Nicolai

 
Adrian Ursu
Reply

8.8 seems very far now :)

Separate pages means a bit more control over the URL.We had to do this ever since 8.3. I don't think we have 2 solutions using only EcomNavigation.
Also, I had to do that because EcomNavigation and ItemBasedPageProperties have not played well together and we needed access to some custom properties.
At least at the moment we have set it up.

If the system would have been more stable and predictable maybe we could have done a better job in implementation. 

We had to do what we had to do to make it work. Sometimes your use cases and ours don't match and we have to improvise.

Thanks,

Adrian

 
Morten Snedker
Reply

I feel like announcing the improved documentaion (but still in progress) of the new index: http://doc.dynamicweb-cms.com/Default.aspx?ID=523

 

Best regards
/Snedker

 
Adrian Ursu
Reply

Awesome!

 
Peter Leleulya
Reply

Awesome!

Awesome!
Awesome!
 
Adrian Ursu
Reply

Hi guys,

I have not checked yet in the schema but maybe you already have an answer for that.

In the provious version of the Index we had the ability to use Variant Options and Product Category Fields in the Search Filters.

Does the Product Schema for new index include these options as well?

Thanks,

Adrian

 
Nicolai Høeg Pedersen
Reply

Yes, it includes those things among others.

If you are missing anything, let us know and we can maybe add it. It is also possible to extend of course, so you can add your own fields.

 
Adrian Ursu
Reply

Thanks a lot.

I will configure a more complex scenario these days and I will let you know if I find something relevant missing.
Adrian

 
Adrian Ursu
Reply

Hi guys,

I just tried to create a query that is supposed to list products from multiple groups.

I have Used Group IDs(System.String[]) on one side and Constant (System.String[]) on the other side.

I have tried putting the values of the GroupID's in quotes, comma separated, tried using System.String.

Nothing worked.

When I used System.String[] I've got a nasty alert error when I saved the Query. I could not copy the error to post it here but I made a screenshot.

Just a reminder, I am using 8.6.16.

Thanks,

Adrian

Screen_Shot_12-21-15_at_01.53_PM.PNG Screen_Shot_12-21-15_at_01.54_PM.PNG
 
Nicolai Høeg Pedersen
Reply

Hi Adrian

Please do not add new issues to an existing thread.

You can use a variable with a default value instead of a contsant - see dump.

BR Nicolai

Capture.PNG
 
Nicolai Høeg Pedersen
Reply

My suggestion does not work.

But another one that will work for now (We have made a bug on the other one). See dump

Capture.PNG
 
Adrian Ursu
Reply

Hi Nicolai,

Thanks for the suggestion.|

I have used "Contains" for the time being because I wanted to list all Men's categories and all Women's categories and all subgroups had Men and Women in their name.
I have used this method so far but I see that your suggestion will work if the subgroups cannot be grabed based on some keyword in name.

Thanks,

Adrian

 
Kristian Kirkholt
Reply

The issues with queries and arrays has now been fixed in version 8.7.2.4

You are able to find this build in the download section:

http://developer.dynamicweb-cms.com/downloads/dynamicweb-8.aspx

Please contact Dynamicweb Support if you need any additional help regarding this.

Kind Regards
Dynamicweb Support
Kristian Kirkholt

 

You must be logged in to post in the forum