Setting up free text search for Ecommerce
In this tutorial, you will learn how to set up a basic free text search for Ecommerce, enabling users to search the:
- Product names
- Short and long descriptions
Of all active Ecommerce products – all from the same text field.
Simply follow this step-by-step guide, and you’re set.
Create a new repository
- Go to you Management Center
- Right click on Repositories and create a new repository
- Name it and click OK
This creates a new repository (Figure 2.1).
Create a new index
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 as your instance)
- Save and close your index – it should look like Figure 3.1
Create your query
- 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 wand 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 wand and select Parameter > Search for all four
- Save and close your query
Use your query
- 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).
- Next, check the Search checkbox - this makes the Search template appear (Figure 5.2)
- In your search template, edit the parameter name to match the name of your parameter (from your query) (Figure 5.3).
- Save and close your module settings
And that’s it. You’re done!
Click Show page and start searching..