Implementing free-text search

This guide will show you how to set up a free text search and use it to search a product list published with the Product Catalog app (Figure 1.1).

We will make it possible for visitors to search on the following data:

  • Product names
  • Short descriptions
  • Long descriptions

Simply follow this step-by-step guide, and you’re set.


A repository is a kind of top folder for indexing configuration files – each repository can contain a number of indexes, queries etc.

Create a new repository:

  • Go to you Settings
  • Right click on the Repositories node and Click New Repository
  • Name it 
  • Click OK

This creates a new repository and opens the configuration page (Figure 2.1).​

Figure 2.1 Your new empty repository should look like this

Next, you must index your content – in this case your products. This is a fairly complicated process, but of course it only needs to be done once, after which the index can be automatically rebuilt at intervals.

Creating a working index requires you to add the elements in the proper order – Index > Instance > Build > Fields.

  • Click Add index
    • Name it
    • Click OK
  • Click Add instance
    • Name it
    • Select the LuceneIndexProvider
    • Provide a folder name
    • Click OK
  • Click Add Build
    • Name it
    • Select the Dynamicweb.eCommerce.Indexing.ProductIndexBuilder
    • Select Full as your builder action
    • Click OK
  • Click Add field
    • Select field type Schema extender
    • Select ProductIndexSchemaExtender as your type
    • Click OK
  • Save your index, then build the index (click the "build"-button next to your build. It has the the same name as your instance)
  • Save and close your index – it should look like Figure 3.1
Figure 3.1 Your index should look like this

 Once you have an index configured and built, you can start querying it – asking it to return information to you.

We will be building a simple query asking for active products containing a particular search term in their name or descriptions.

  • Click Add query
    • Name it
    • Select your index as data source
    • Click OK
  • Click Add parameter
    • Name it (e.g. Search)
    • Select System.String as type
    • Click OK
  • Click Expressions > Add group
    • In the dropdowns, select the Active field and the Equal operator.
    • Click the pencil and select Constant & System.Boolean. Set value to true.
    • Click Add group and select the OR operator in the dropdown
    • Add four expressions (Figure 4.1)
      • Select Product name, Product number, Short description and Long description from the dropdowns
      • Select Contains as the operator
      • Click the pencil and select Parameter > Search for all four
  • Save and close your query
Figure 4.1 Your expressions should look like this

  • Go to the Product Catalog module settings on your paragraph
  • Under the Show settings, select Index
  • Under the Index settings, select your query
  • Under Templates, open the ProductList template and add <!--@Ecom:Search.SearchBox--> where you want the search box to appear (Figure 5.1).
Figure 5.1 Insert the tag where you want your search box to appear
  • Next, check the Search checkbox - this makes the Search template appear (Figure 5.2)
Figure 5.2 Check the Search checkbox to enable (and edit) the search result template
  • In your search template, edit the parameter name to match the name of your parameter (from your query) (Figure 5.3).
Figure 5.3 Change the Search template to match your parametername from your query
  • Save and close your module settings

And that’s it. You’re done! 

Click Show page and start searching..