Search Queries

The search:query tag instantiates a search query that can be submitted to Fusion. The search:query tag can use all applicable parameters from the query string (HTTP request) to create a query object. Queries can also include filters. You can use the query:filter tag and the query:custom tag in the body of a search:query tag to add invariant query filters or custom engine parameters, respectively.

Usage example

As an example, imagine the URL of the page looks like this:

http://intranet/search?q=guidelines&rpp=10

In this example, guidelines is the query term, and the resultsPerPage attribute (rpp) is limited to 10.

You can override the rpp to fix how many results should be displayed per page, or override the value specified in the URL query string. To do this, append the search:query tag with the long-form name of the attribute you want to override:

<search:query var="query" parameters="*" results-per-page="5" />

You can also clone a query instance using the from attribute:

<search:query var="query" from="${otherQuery}" resultsPerPage="5" />

Query Parameters

In the table below, we list all query parameters that can be specified as attributes on the search:query tag. For each parameter, we also list the corresponding short form that is used to encode the parameter in a URL request.

Parameter Description Default

var (String)

This is the name of the variable into which the query object is stored.

query

parameters (String)

The list of URL parameters to consider when constructing a new query instance. Setting parameters to means that all parameters from the HTTP request are used to create a new query. You can specify a comma-separated list of parameters. You can also use negation (-) in conjunction with a wildcard to exclude one or more parameters; for example, ,-rpp means that we look at all URL parameteres except for rpp.

from (String)

Create a new query from existing query object.

Note
For the parameters below, parameters in the URL override parameters in the search:query tag. To ignore URL parameters and always use the parameter in the tag, exclude the URL parameters by negating them with a hyphen (-) in the parameters attribute. For example, to ignore any occurrences of rpp in URLs, use -rpp, like this: <search:query parameters='*,-rpp' results-per-page="5">

query (&q=) (String)

Use the query (or q) parameter to specify the query term to use.

modified-query (&mq=) (String)

Specify an alternative query which is submitted to the search engine in place of the query parameter supplied by the user (but can include user-submitted parameters). To the user, it appears as if the query parameter had been used, but the modified-query is submitted to the search engine.

type (&t=) (String)

Specifies how to interpret multiple query terms. Takes one of three values:

  • any (boolean OR the terms)

    For example, take the query "apple ipod". With type=“any”, documents containing either term (apple OR ipod) are returned.

  • all (boolean AND the terms)

    Documents containing both terms (apple AND ipod) are returned.

  • adv (interpret using search platform-specific advanced query language)

any

results-per-page (&rpp=) (Integer)

The number of results to display per page.

10

max-results (&max=) (Integer)

The maximum number of results to evaluate. Defaults to -1, which means no upper limit.

-1

page (&p=) (Integer)

Set the page of results to display. The default value is 1 (1-based index), which would display the first page of results.

1

facets (&fa=) (String)

Specifies which facets to evaluate and return. Specified as a comma-separated list without spaces (such as facets=“cat,inStock”). This overrides the defaultFacets parameter of the search:platform tag.

fields (&fi=) (String)

A comma-separated list of fields that should be returned in the response.

sorts (&s=) (String)

Specifies fields and order for sorting. Sort order is specified by one of two characters:

  • + for ascending

  • - for descending

To sort ascending by the field price, the sort is specified as sorts=“+price”. Multilevel sorting is supported. To sort by multiple levels using the search:query tag, use & to separate the values. For example, to sort by price ascending and then SKU descending, use sorts=“+price&-sku”. To do the same using the URL query string, use multiple instances of the s parameter, such as ?&s=+price&s=-sku.

view (&v=) (String)

Set which search engine view to use. Behaviour is engine-dependent.

collection (&co=) (String)

Set which search engine collection to search against.

filters (&f=) (String)

Specifies filters to apply, specified as an ampersand (&) separated string. In the query string, however, there are multiple &f= arguments. Filters are used to restrict field values that appear in results. We generally recommend using the query:filter tag for adding query filters instead of specifying them as an encoded string with this option.

custom (&c=) (String)

The custom attribute lets you send custom parameters to the search platform. Parameters are specified using the format parameter[value] for a single parameter and corresponding value. Multiple parameters can be submitted with the search:query tag by separating them with & characters, as in custom=“parameter1[value1]&parameter2[value2]“. To submit multiple custom parameters using the URL query string, use multiple instances of the c parameter, such as ?c=parameter1[value1]&c=parameter2[value2]. We generally recommend using the query:custom tag for adding custom parameters instead of specifying them as an encoded string with this option.