Defining Query Templates

Exalead CloudView supports combining multiple chunks of queries, that we call “named queries”, to build the final query. The combination of all named queries is specified by the query template defined in Search > Search Logics > Your search logic > Query Template.

This page discusses:

Query Template Syntax

The default query template string is:

#and(#query(relevance_tuning) #and(#query(_default_) #query(refine) #query(security) #query(restriction) 
#query(date_restriction) #query(geo_restriction)))

The parameters following #query are replaced by named queries, whose names are specified between parentheses. For example, relevance_tuning is the name of the first named query. You can reference the default query (q in UQL or eq in ELLQL) in the query template with #query(_default_).

The query template is itself an ELLQL query that you can set dynamically using the qt parameter. For example, with a query template of qt=#and(#query(a) #query(b))

  • passing in q.a=word1 OR word2 and q.b=word3 OR word4

  • results in a final query of (word1 OR word2) AND (word3 OR word4)

    Note: Through the API, you can pass additional queries using the q.NAME parameter family. You can pass additional queries as ELLQL, using the eq.NAME parameter family.

Options can be passed to the named queries specified after #query in the query template and forwarded to top nodes. The options forwarded from the query template always override the options that might be already present on the top nodes. For example, qt=#and(#query{w=0.5}(a) #query(b))

  • passing in q.a=word1{w=2} and q.b=word2

  • results in a final query of word1{w=0.5} AND word2

Note: The query template and the named queries are parsed (and expanded) separately. Then, the query template and the named queries are merged into a single query, with the options of the query template forwarded to the top nodes of the named queries. Remind that no query expansion is performed on the query template itself, which is only parsed. Query expansion is performed in detached expanded queries.

For example:

  • If the query template is: #and(#query{foo=bar}(_example_) #false)

  • and the _example_ named query in the search field is: #fuzzyand(#or(#true))

  • the expanded query is: #and(#fuzzyand{foo=bar}(#or(#true)) #false)

Reserved Named Queries

  • refine: all refinement parameters (r, cr, zr) are interpreted by the query parser, generating a named query called refine.

  • security: all security tokens are interpreted and combined as a large OR query, generating a named query called security.

  • restriction: generated by the content restriction specified in the search logic.

Use Case

It could be useful to add a restriction to user queries coming from a specific Mashup page of your front-end search application. Rather than modifying the user query, you could pass a named query and specify how you want queries to be combined to handle this restriction.

For example, we could add the named query confidential_doc to the query template to exclude confidential documents from the search results. This is already managed in the default query template by #query(security) checks user security tokens if any.