Search queries enable you to search for components stored in FlowerDocs according to various criteria. These search queries are composed as follows:
The different clauses
Select clause
Use selectClause
to define the fields to be brought up. It consists of a list of fields
values.
Clauses Filter
Use filterClauses
to define filters to be applied to the search. A filterClause
is composed as follows:
criteria
: filter criteriafilterClauses
: les sous-filters
A Filter clause can contain one or more other clauses, enabling you to perform complex queries with logical AND and OR operators. There are two types of Filter clause for this purpose:
AndClause
: Clause AND, a logical AND operator is applied between its criteria and sub-clausesOrClause
: Clause OR, a logical OR operator is applied between its criteria and sub-clauses
Clauses Order
The orderClauses
allow you to define the order in which results will be returned. They are composed as follows:
name
: the name of the criterion on which to sorttype
: type of criterionascending
: sorting in ascending or descending order
Pagination of results
start
: Defines the start of the search pagemax
: Defines the maximum number of results to be returned
Examples
The examples below show how to search for a document with a name containing the invoice
string.
POST {{core}/rest/documents/search HTTP/1.1
-- URL parameters --
core: FlowerDocs Core host
-- Headers --
token: {{token}
Content-Type: application/json
--Body (json) --
{
"filterClauses": [
{
"criteria": [
{
"name": "name",
"operator": "CONTAINS",
"type": "STRING",
"values": [
"invoice"
]
}
]
}
],
"max": 10
}
@Autowired
private DocumentService documentService;
public void search() throws FunctionalException, TechnicalException
{
Criterion criterion = CriterionBuilder.field(NAME).operator(CONTAINS).value("facture").build();
FilterClause filter = FilterClauseBuilder.init().criterion(criterion).build();
SearchRequest request = SearchRequestBuilder.init().filter(filter).build();
SearchResponse response = documentService.search(request);
}
CONTAINS
operator is not case-sensitive (does not distinguish between upper and lower case), unlike the EQUALS_TO
and DIFFERENT
operators.
So the above example will retrieve documents whose name contains: “invoice”, but also “INVOICE”, “Invoice” …
These examples need to be adapted for each component category.