Skip to main content

Query Types

Risksheet supports two query syntaxes:
SyntaxPrefixDescription
Lucene(none)Default Polarion query syntax for work item filtering
SQLSQL:(...)SQL queries for complex work item filtering

Lucene Query Basics

Lucene queries filter work items based on field values using standard Polarion query syntax.

Operators

OperatorSyntaxExampleDescription
Equalsfield:valuetype:riskField equals exact value
NOTNOT field:valueNOT status:closedField does not equal value
ANDexpr1 AND expr2type:risk AND status:openBoth conditions must match
ORexpr1 OR expr2type:risk OR type:hazardEither condition must match
Wildcardfield:val*title:brake*Wildcard matching
Quotedfield:"value"title:"Brake Failure"Exact phrase matching
Grouping(expr1 OR expr2)(type:risk OR type:hazard) AND status:openLogical grouping

Common Fields

FieldDescriptionExample
typeWork item typetype:risk
statusWorkflow statusstatus:open
project.idProject identifierproject.id:AutoSafety
moduleDocument/module pathmodule:"Risks/FMEA"
idWork item IDid:RISK-001
titleWork item titletitle:"Brake Failure"
linkedWorkItemsLinked item referenceslinkedWorkItems:REQ-001

Query Assembly

diagram The final query is assembled by combining four components with AND logic:
  1. Type filter — Work item types from dataTypes.<type>.types, combined with OR if multiple
  2. Project scope — Current project identifier
  3. Document scope — Current document/module path (quoted to handle spaces)
  4. Custom query — Additional user-defined conditions from the query property
Empty conditions are automatically skipped. At least one work item type must be specified or the system returns an error.

Query in Configuration

Data Type Query

The dataTypes configuration uses the query property to add custom filtering to the generated query:
{
  "dataTypes": {
    "risk": {
      "types": ["fmea_risk"],
      "role": "relates_to",
      "query": "NOT status:rejected"
    },
    "task": {
      "types": ["mitigation"],
      "role": "mitigates",
      "query": "NOT status:closed"
    }
  }
}
PropertyTypeDefaultDescription
dataTypesobject{}Configures risk and task data types including query factories, work item types, roles, and menu visibility
dataTypes.<name>.typesarrayRequiredWork item types to include. Multiple types combined with OR logic
dataTypes.<name>.querystring""Custom Lucene query fragment appended with AND logic
dataTypes.<name>.rolestringSee applicationLink role used for item relationships

Escaped Quotation Marks in JSON

When embedding queries with quotation marks inside risksheet.json, use backslash escaping:
{
  "dataTypes": {
    "risk": {
      "types": ["fmea_risk"],
      "query": "customField:\"specific value\" AND category:\"safety\""
    }
  }
}
Use \" to include quotation marks within JSON string values. This is standard JSON escaping and applies to all query strings in risksheet.json.

SQL Query Support

Risksheet supports SQL queries for complex filtering scenarios using the SQL:(...) prefix:
{
  "dataTypes": {
    "risk": {
      "query": "SQL:(SELECT wi FROM WorkItem wi WHERE wi.project.id = 'AutoSafety')"
    }
  }
}
SQL query syntax and available tables/fields depend on your Polarion server version. Verify supported SQL constructs in your environment before deploying.

Query Factory

Query factories provide dynamic query filtering through custom JavaScript functions registered on the window.risksheet.queryFactories object. They enable context-aware filtering of linked items in autocomplete dropdowns.
{
  "columns": [
    {
      "binding": "linkedRequirement",
      "header": "Linked Requirement",
      "type": "itemLink",
      "queryFactory": "requirementFilter"
    }
  ]
}
Register the factory in a top panel script or external JavaScript:
window.risksheet = window.risksheet || {};
window.risksheet.queryFactories = window.risksheet.queryFactories || {};
window.risksheet.queryFactories["requirementFilter"] = function(column, item) {
  return "type:requirement AND status:approved";
};
FeatureDescription
Autocomplete filteringCustomizes which items appear in autocomplete suggestion dropdowns
Context-aware searchFactory function receives the current column and row item, enabling dynamic filtering
Link editor integrationApplied to item link, multi-item link, and task link column editors
See JavaScript API for the full query factory API.

Document Path Handling

Document IDs with _default/ prefix (default modules) have the prefix automatically stripped before query construction. Document paths containing spaces or special characters are automatically quoted in the generated query.

Autocomplete Search Behavior

The autocomplete suggestion system uses queries to search for matching work items:
ParameterTypeDefaultDescription
Fuzzy searchBooleanSee applicationEnables approximate matching for spelling variations
Wildcard searchBooleanSee applicationAllows * wildcard characters in search terms
Keyword matchingBooleanSee applicationWhen enabled, all search terms must be present (AND logic)
Result limitNumber50Maximum number of suggestion results returned
Minimum query lengthNumber3Minimum characters before autocomplete activates
Suggestions are automatically scoped to the current project. Cross-project suggestions are not available in the default autocomplete. Newly created items that have not been saved appear in suggestions for the current session.
See Suggestion and Autocomplete API for the full API reference.

Complete Example

A full configuration demonstrating query usage across data types and columns:
{
  "dataTypes": {
    "risk": {
      "types": ["fmea_risk"],
      "role": "relates_to",
      "query": "NOT status:rejected AND customField:\"productFamily_A\""
    },
    "task": {
      "types": ["mitigation", "verification"],
      "role": "mitigates",
      "query": "NOT status:closed"
    }
  },
  "columns": [
    {
      "binding": "linkedRequirement",
      "header": "Requirement",
      "type": "itemLink",
      "queryFactory": "requirementFilter",
      "canCreate": true
    },
    {
      "binding": "linkedHazard",
      "header": "Hazard",
      "type": "itemLink",
      "queryFactory": "hazardFilter"
    }
  ]
}
This configuration:
  • Loads FMEA risk items for productFamily_A, excluding those with rejected status
  • Loads both mitigation and verification task types, excluding closed items
  • Provides item link columns for requirements (with creation) and hazards, each with custom query factory filtering
Support TicketsSource Code
  • QueryBuilder.java
  • AppConfig.ts
  • MultiItemLinkEditor.ts
  • SuggestionServlet.java
  • OpenInTableCommand.ts