Studio provides the following QueryConfig functions, used to manage the results returned by a query. These are more advanced functions for component development.
Each QueryConfig function generally has a corresponding function in DiscoveryServiceUtils to get the results.
QueryConfig functions are most often used to obtain results that are specific to a component. Because of this, QueryConfig functions should never be persisted to the application data domain using setQueryState(), as this would affect all of the components that are bound to the same data. Instead, QueryConfig functions should only be added to a component's local copy of the QueryState object.
The available QueryConfig functions are:
In addition to the information here, for more details on the QueryConfig functions, see the Component SDK API Reference.
Used for text searches, such as in the Available Refinements panel and the Search Box functions.
AttributeTextValueSearchConfig has the following properties:
| Property | Description |
|---|---|
| searchTerm | String
The term to search for in the attribute values. |
| attribute | String (optional)
The attribute key for the attribute to search in. Use the attribute property to search against a single attribute. To search against multiple attributes, use searchWithin. |
| searchWithin | List<String>
(optional)
A list of attributes to search in for matching values. |
| languageId | String (optional)
The country code for a supported language (such as "en" for English). |
AttributeTextValueSearchConfig attributeTextValueSearchConfig = new AttributeTextValueSearchConfig("merlot");
Used for type-ahead in a search field. For example, used for Available Refinements to narrow down the list of available values for an attribute.
AttributeValueSearchConfig has the following properties:
| Property | Description |
|---|---|
| searchTerm | String
The term to search for in the attribute values. |
| maxValuesToReturn | int (optional)
The maximum number of matching values to return. If you do not provide a value, then the default is 10. |
| attribute | String (optional)
The attribute key for the attribute to search in. Use the attribute property to search against a single attribute. To search against multiple attributes, use searchWithin. |
| searchWithin | List<String>
(optional)
A list of attributes to search in for matching values. |
| matchMode | ALL|PARTIAL|ANY|ALLANY|ALLPARTIAL|PARTIALMAX|BOOLEAN
(optional)
The match mode to use for the search. |
| relevanceRankingStrategy | String (optional)
The name of the relevance ranking strategy to use during the search. |
| languageId | String (optional)
The country code for a supported language (such as "en" for English). |
The following example searches for the term "red" in the WineType attribute values:
AttributeValueSearchConfig attributeValueSearchConfig = new AttributeValueSearchConfig("red", "WineType");
Used to return the refinements associated with the query.
BreadcrumbsConfig has the following property:
| Property | Description |
|---|---|
| id | String (optional)
The ID of the breadcrumbs to be instantiated. |
This example returns the refinements:
BreadcrumbsConfig breadcrumbsConfig = new BreadcrumbsConfig();
Executes an EQL query on top of the current filter state.
LQLQuery has the following property:
| Property | Description |
|---|---|
| lqlQuery | AST
The EQL query to add. To retrieve the AST from the query string, call DataSource.parseLQLQuery. |
The following example retrieves the average of the P_Price attribute grouped by Region:
Query query = dataSource.parseLQLQuery("return mystatement as select avg(P_Price) as avgPrice group by Region", true);
LQLQueryConfig lqlQueryConfig = new LQLQueryConfig(query);
Sends an attribute key-value pair to assemble the details for a selected record. The complete set of attribute-value pairs must uniquely identify the record.
RecordDetailsConfig has the following property:
| Property | Description |
|---|---|
| recordSpecs | List<RecordSpec>
Each new RecordDetailsConfig is appended to the previous RecordDetailsConfig. |
The following example sends the value of the P_WineID attribute:
List<RecordSpec> recordSpecs = new ArrayList<RecordSpec>();
recordSpecs.add(new RecordSpec("P_WineID", "37509"));
RecordDetailsConfig recordDetailsConfig = new RecordDetailsConfig(recordSpecs);
Used to manage the returned records. Allows for paging of the records.
ResultsConfig has the following properties:
| Property | Description |
|---|---|
| recordsPerPage | Long
The number of records to return at a time. |
| offset | Long (optional)
The position in the list to start at. The very first record is at position 0. For example, if recordsPerPage is 10, then to get the second page of results, the offset would be 10. |
| columns | String[] (optional)
The columns to include in the results. If not specified, then the results include all of the columns. |
| numBulkRecords | Integer (optional)
The number of records to return. Overrides the value of recordsPerPage. |
The following example returns a selected set of columns for the third page of records, where each page contains 50 records:
ResultsConfig resultsConfig = new ResultsConfig();
resultsConfig.setOffset(100);
resultsConfig.setRecordsPerPage(50);
String[] columns = {"WineID", "Name", "Description", "WineType", "Winery", "Vintage"};
resultsConfig.setColumns(columns);
Gets the number of records returned from a query.
ResultsSummaryConfig resultsSummaryConfig = new ResultsSummaryConfig();
Returns DYM (Did You Mean) and auto-correction items for a search.
SearchAdjustmentsConfig searchAdjustmentsConfig = new SearchAdjustmentsConfig();
Used to sort the results of a query. Used in conjunction with ResultsConfig.
SortConfig has the following properties:
| Property | Description |
|---|---|
| ownerId | String (optional)
The ID of the ResultsConfig that this SortConfig applies to. If not provided, uses the default ResultsConfig ID. If you configure a different ID, then you must provide a value for ownerId. |
| property | String
The attribute to use for the sort. |
| ascending | Boolean
Whether to sort in ascending order. If set to false, then the results are sorted in descending order. |
For example, with the following SortConfig, the results are sorted by the P_Score attribute in descending order:
SortConfig sortConfig = new SortConfig("P_Score", false);