Queries

Where warehouses and groups allow you to organize your products in a structured manner, queries allow you to retrieve products which are similar in some way – regardless of their place in the warehouse group hierarchy. If you are familiar with the Dynamicweb indexing framework, you should be familiar with the basics of indexing and queries.

Think of queries as a sort of dynamic warehouse group, which contains all products that share certain customizable properties. You could, for example, create a query which returns all product created after a certain date with no product name. Or a query which returns all products with less than 100 stock.

A query is associated with a particular product index and consists of:

  • A set of expressions which filter the products returned – no expressions means all products are returned
  • Sorting instructions
  • Instructions for which fields and languages to show for the products returned

Queries may be personal or shared, and can be organized in folders and subfolders if necessary (Figure 1.1).

  • Queries created under My Queries are personal and cannot be used by other users
  • Queries created under Shared Queries are shared amongst all users on the solution
Figure 1.1 Shared & personal queries

To create a query:

  • Right click on either My Queries or Shared Queries in the PIM tree
  • Click New Query
  • Name the query
  • Select a product index as the data source
  • Click OK

This will open the query configuration view which is used to define expressions, sorting, and display instructions.

The way queries work, an empty query returns all data in the index. This is usually not very useful, so you create sets of expressions which limit the data returned and create specialized, manageable lists for you to work with.

For instance, you may want to isolate all active products with no description (Figure 2.1), or perhaps you are only interested in products which are a part of the Christmas campaign.

To create expressions:

  • Click Add Group
  • Select a field in the index
  • Select an operator
  • If the operator requires it, set a test value
  • Click OK
Figure 2.1 Query expressions

The operators and test values available are dependent on the data type of the field you query. For instance, a Boolean is a data type which can only be true or false – and so the only operator available is ‘Equal’ and the only test values available are true and false.

Expressions may be combined in AND-groups and OR-groups, and can be negated to return all elements not matching the expressions. This makes it possible to create pretty powerful and complex queries.

For more information regarding expressions, please consult the indexing documentation.

When a query is executed, the products matching the expression criteria will be rendered in the content pane, where you can review and work with them using the views available to you (see below).

By default, products are sorted by ProductID, but you can define a default sort order in the query definition (Figure 3.1).

Figure 3.1 Creating a default sort order

To do so:

  • Click Add Sorting
  • Select a Field and a Direction
  • Click OK

Don’t forget to save the query before exiting. To remove a default sort order click the red X and save.

Next, you can define which fields and languages are shown by default when a query is accessed in the Multi-Edit view mode (Figure 4.1). 

You can either:

  • Select a predefined field group
  • Create a selection manually using the Fields and Languages selectors
Figure 4.1 Display instructions for a query

A few things to keep in mind:

  • The more fields and languages you include, the slower the PIM list will be to work with – this is a browser memory issue, not a Dynamicweb issue
  • The fields and languages are listed in the same order they have on the right side of the selector, so you should sort them to your liking using the sorting arrows

Of course, when working with a query result you always have the option of adding or removing fields and languages from the present view. The display configurations are merely default instructions for the Edit view mode.

If a query matches only a particular variant, the rest of the variant cluster (master & non-matching variants) will be displayed in a dim grey, which will help you identify the relevant products in a speedy manner.

The visible fields selector can override this predefined selection, but the view will revert to the fields defined here the next time the query is accessed.

Finally, you can select one or more completion rules and apply them to the query (Figure 5.1). Completion rules calculate how wel a product has been enriched for a various purposes. Read more in the Product Enrichment article.

Figure 5.1 Adding completion rules to a query