- Print
- DarkLight
- PDF
General Search API
This API meets the following needs:
- Enable advanced searches and use the same mechanics as advanced UI search via APIs
- Have an API optimized for advanced search
Permissions
See the OAuth2 article to generate the token.
HTTP request
POST beta/records/search
Request header
Parameter | Description |
---|---|
Authentication | Bearer {token}. Obligatory. |
Request Body
Settings | Type | Description |
---|---|---|
Query | Thong | The json search query |
In the query parameter we have the properties described in the table below:
Properties | Type | Description | Status |
searchTerms | String | Search by simple text | Optional |
collection | String | The collection on which the research is being done | Obligatory |
schemaType | String | The type of schema | Obligatory |
filter | Object(See Filter section) | Filter with logical operators AND, OR, or NOT on metadata | Optional |
searchParams | Object (See SearchParams section) | Setting up search results | Optional |
Sorting | List (See Sorting section) | Sorting results on metadata | Optional |
Filter
Allows you to define a simple condition on a metadata, to nest conditions with the OR, AND operators. The supported comparison operators are as follows:
Operator | Example of use | Description |
Eq | { "metadata": "title", "eq":"guide" } | The equality operator. Tests if the metadata is equal to the value provided |
Bt | { "metadata": "openingDate", "bt": { "min": " 2000-10-03", "max": "2023-11-05" } } | The Beetween Operator . Tests whether the metadata falls within the range provided. |
Ct | { "metadata": "numberMetadata", "ct": [ 88, 90 ] } | The contains. Tests whether the metadata contains the values provided. This operator is used on multi-valued metadata that is different in type than string. |
ctText | { "metadata": "title", "ctText": "Bee" } | The contains text. Operator tests whether the metadata contains the provided text. |
Gt | { "metadata": "openingDate", "gt":"2000-11-08" } | The operator greater than. Tests whether the value of the metadata is greater than the value provided. |
Lt | { "metadata": "openingDate", "lt":"2000-11-08" } | The operator lower than. Tests whether the value of the metadata is less than the value provided. |
startsWith | { "metadata": "title", "startsWith": "Bee" } | The operator starts with. Tests whether the metadata value starts with the value provided. |
endsWith | { "metadata": "title", "endsWith": "Bee" } | The operator ends with. Tests whether the metadata value ends with the value provided. |
NCT | { "metadata": "numberMetadata", "nct": [ 88, 90 ] } | The NOT contains. Tests whether the metadata does not contain the values provided. This operator is used on multi-valued metadata that is different in type than string. |
nctText | { "metadata": "title", "nctText": "Bee" } | The NOT contains text. Operator tests whether the metadata does not contain the supplied text. |
isTrue | { }"isTrue": "hasContent" | The operator is true. Tests whether the metadata value is true. |
isFalse | { "isFalse": "hasContent" } | The operator is False. Tests whether the metadata value is false. |
isNull | { "isNull": "actualDestructionDate" } | The operator is null. Tests whether the metadata value is null. |
isNotNull | { "isNotNull": "actualDestructionDate" } | The operator is not null. Tests whether the metadata value is not null. |
SearchParams
It allows you to manage the parameterization of search results by defining the number of results to be returned, from which index, the metadata to be returned, highlighting, calculating or applying facets.
Properties | Type | Descriptions | Status |
resultCount | Int | The number of results to display | Facultative |
startIndex | Int | The beginning of the index to display the results. Default | Facultative |
Hl | List<String> or enum with values DEFAULT, SUMMARY | To highlight(highlight) | Facultative |
Metadata | List<String> or enum with values ALL, RESULTS, SUMMARY | You can define in a list the metadata to be returned or choose one of the ALL, RESULTS or SUMMARY modes | Facultative |
Facets | Facet object (see Facet section) | To Calculate or Apply Facets | Facultative |
Corrector | Boolean | To enable the suggestion | Facultative |
showOnlyWriteAccess | Boolean | To display only records for which you have write rights | Facultative |
Facet
Properties | Type | Descriptions | Status |
computeFacet | Boolean | To Calculate Facets | Facultative |
facetMode | Enum with values NONE, CONSTELLIO, SPECIFIC |
| Facultative |
selectedFacet | List | The list of facets to be applied. In each of the facets, the metadata and values are filled in. Like here: "selectedFacets": [{"metadata": " copyStatus", "values": ["P"]}] | Facultative |
Sorting
Properties | Type | Descriptions | Status |
Metadata | String | Metadata | Obligatory |
Ascending | Boolean | The type of ascending or descending sort | Obligatory |
Before interacting with the API, make sure that you follow the following request JSON schema:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Constellio Search Expression",
"type": "object",
"properties": {
"searchTerms": {
"type": "string",
"nullable": true
},
"collection": {
"type": "string",
"nullable": false
},
"schemaType": {
"type": "string",
"nullable": false
},
"filter": {
"$ref": "#/definitions/filterCondition"
},
"searchParams": {
"$ref": "#/definitions/searchParamsDefinition"
},
"sorting": {
"type": "array",
"items": {
"type": "object",
"properties": {
"metadata": {
"type": "string"
},
"ascending": {
"type": "boolean"
}
}
}
}
},
"definitions": {
"arrayOfString": {
"type": "array",
"items": {
"type": "string"
}
},
"returnedMetadatasMode": {
"type": "string",
"enum": [
"ALL",
"RESULTS",
"SUMMARY"
]
},
"highlightingMode": {
"type": "string",
"enum": [
"DEFAULT",
"SUMMARY"
]
},
"searchParamsDefinition": {
"type": "object",
"properties": {
"resultCount": {
"type": "integer"
},
"startIndex": {
"type": "integer"
},
"hl": {
"description": "highlighting on a set of metadata or choose the highlighting mode(DEFAULT, SUMMARY)",
"oneOf": [
{
"$ref": "#/definitions/highlightingMode"
},
{
"$ref": "#/definitions/arrayOfString"
}
]
},
"metadatas": {
"description": "returned metadatas. You can define the list of metadata to return or choose the mode(ALL,CACHED,RESULTS)",
"oneOf": [
{
"$ref": "#/definitions/returnedMetadatasMode"
},
{
"$ref": "#/definitions/arrayOfString"
}
]
},
"facets": {
"$ref": "#/definitions/facetsDefintion"
},
"corrector": {
"type": "boolean"
},
"showOnlyWriteAccess": {
"type": "boolean"
}
}
},
"facetsDefintion": {
"type": "object",
"additionalProperties": false,
"properties": {
"computeFacets": {
"type": "boolean"
},
"facetMode": {
"type": "string",
"enum": [
"NONE",
"CONSTELLIO",
"SPECIFIC"
]
},
"selectedFacet": {
"type": "array",
"items": {
"$ref": "#/definitions/selectedFacetItem"
}
}
},
"required": [
"computeFacets"
]
},
"selectedFacetItem": {
"type": "object",
"properties": {
"metadata": {
"type": "string"
},
"values": {
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": false
},
"metadataDefinition": {
"type": "string"
},
"eqOperator": {
"type": "object",
"additionalProperties": false,
"properties": {
"metadata": {
"$ref": "#/definitions/metadataDefinition"
},
"eq": {
"type": "string"
}
},
"required": [
"metadata",
"eq"
]
},
"betweenOperator": {
"type": "object",
"additionalProperties": false,
"properties": {
"metadata": {
"$ref": "#/definitions/metadataDefinition"
},
"bt": {
"type": "object",
"additionalProperties": false,
"properties": {
"min": {
"type": "string"
},
"max": {
"type": "string"
},
"rangeIsIncluded": {
"type": "boolean"
}
},
"required": [
"min",
"max"
]
}
},
"required": [
"metadata",
"bt"
]
},
"gtOperator": {
"type": "object",
"additionalProperties": false,
"properties": {
"metadata": {
"$ref": "#/definitions/metadataDefinition"
},
"gt": {
"type": "string"
}
},
"required": [
"metadata",
"gt"
]
},
"ltOperator": {
"type": "object",
"additionalProperties": false,
"properties": {
"metadata": {
"$ref": "#/definitions/metadataDefinition"
},
"lt": {
"type": "string"
}
},
"required": [
"metadata",
"lt"
]
},
"startsWithOperator": {
"type": "object",
"additionalProperties": false,
"properties": {
"metadata": {
"$ref": "#/definitions/metadataDefinition"
},
"startsWith": {
"type": "string"
}
},
"required": [
"metadata",
"startsWith"
]
},
"endsWithOperator": {
"type": "object",
"additionalProperties": false,
"properties": {
"metadata": {
"$ref": "#/definitions/metadataDefinition"
},
"endsWith": {
"type": "string"
}
},
"required": [
"metadata",
"endsWith"
]
},
"containsOperator": {
"type": "object",
"additionalProperties": false,
"properties": {
"metadata": {
"$ref": "#/definitions/metadataDefinition"
},
"ct": {
"type": "string"
}
},
"required": [
"metadata",
"ct"
]
},
"notContainsOperator": {
"type": "object",
"additionalProperties": false,
"properties": {
"metadata": {
"$ref": "#/definitions/metadataDefinition"
},
"nct": {
"type": "string"
}
},
"required": [
"metadata",
"nct"
]
},
"isTrueOperator": {
"type": "object",
"additionalProperties": false,
"properties": {
"isTrue": {
"type": "string"
}
},
"required": [
"isTrue"
]
},
"isFalseOperator": {
"type": "object",
"additionalProperties": false,
"properties": {
"isFalse": {
"type": "string"
}
},
"required": [
"isFalse"
]
},
"isNullOperator": {
"type": "object",
"additionalProperties": false,
"properties": {
"isNull": {
"type": "string"
}
},
"required": [
"isNull"
]
},
"isNotNullOperator": {
"type": "object",
"additionalProperties": false,
"properties": {
"isNotNull": {
"type": "string"
}
},
"required": [
"isNotNull"
]
},
"metadataCondition": {
"type": "object",
"anyOf": [
{
"$ref": "#/definitions/betweenOperator"
},
{
"$ref": "#/definitions/eqOperator"
},
{
"$ref": "#/definitions/gtOperator"
},
{
"$ref": "#/definitions/ltOperator"
},
{
"$ref": "#/definitions/startsWithOperator"
},
{
"$ref": "#/definitions/endsWithOperator"
},
{
"$ref": "#/definitions/containsOperator"
},
{
"$ref": "#/definitions/notContainsOperator"
},
{
"$ref": "#/definitions/isTrueOperator"
},
{
"$ref": "#/definitions/isFalseOperator"
},
{
"$ref": "#/definitions/isNullOperator"
},
{
"$ref": "#/definitions/isNotNullOperator"
}
]
},
"filterConditionList": {
"type": "array",
"items": {
"$ref": "#/definitions/filterCondition"
}
},
"andLogicalOperator": {
"type": "object",
"additionalProperties": false,
"properties": {
"and": {
"$ref": "#/definitions/filterConditionList"
}
},
"required": [
"and"
]
},
"orLogicalOperator": {
"type": "object",
"additionalProperties": false,
"properties": {
"or": {
"$ref": "#/definitions/filterConditionList"
}
},
"required": [
"or"
]
},
"notLogicalOperator": {
"type": "object",
"additionalProperties": false,
"properties": {
"not": {
"$ref": "#/definitions/filterConditionList"
}
},
"required": [
"not"
]
},
"filterCondition": {
"oneOf": [
{
"$ref": "#/definitions/andLogicalOperator"
},
{
"$ref": "#/definitions/orLogicalOperator"
},
{
"$ref": "#/definitions/metadataCondition"
},
{
"$ref": "#/definitions/notLogicalOperator"
}
]
}
}
}
Examples
{
"searchTerms": "",
"collection": "zeCollection",
"schemaType": "document",
"filter": {
"and": [
{
"or": [
{
"metadata": "administrativeUnit",
"eq": "unitId_10"
},
{
"isTrue": "hasContent"
},
{
"metadata": "title",
"ctText": "guide"
}
]
},
{
"metadata": "openingDate",
"bt": {
"min": "2000-10-03",
"max": "2000-11-05"
}
},
{
"or": [
{
"metadata": "openingDate",
"gt": "2000-11-08"
},
{
"metadata": "title",
"startsWith": "Crocodile"
},
{
"isNotNull": "actualDestructionDate"
}
]
}
]
},
"searchParams": {
"resultCount": 15,
"startIndex": 0,
"metadatas": "SUMMARY",
"facets": {
"computeFacets": true,
"facetMode": "SPECIFIC",
"selectedFacets": [
{
"metadata": "copyStatus",
"values": [
"P"
]
}
]
}
},
"sorting": [
{
"metadata": "title",
"ascending": true
}
]
}
Response
{
"totalRowCount": 15,
"startRow": 0,
"endRow": 2,
"page": 1,
"totalPages": 5,
"suggestions": [],
"recordsResult": {
"records": [
{
"id": "00000200221",
"schemaType": "document",
"metadatas": {
"sameSemiActiveFateAsFolder": [
"true"
],
"visibleInTrees": [
"false"
],
"caption": [
"Avocat / Avocat - Petit guide"
],
"type": [
"documentTypeId_3"
],
"title": [
"Avocat - Petit guide"
],
"createdOn": [
"2023-09-27T13:07:40.972"
],
"principalpath": [
"/admUnits/unitId_10/unitId_12/unitId_12b/B52/00000200221"
],
"modifiedOn": [
"2023-09-27T13:07:40.972"
],
"estimatedSize": [
"2750"
],
"archivisticStatus": [
"INACTIVE_DESTROYED"
],
"currentContentSize": [
"0.0"
],
"copyStatus": [
"PRINCIPAL"
],
"principalAncestorsIntIds": [
"-128",
"-69",
"-48",
"-4"
],
"borrowed": [
"false"
],
"contentVersionsCount": [
"0"
],
"confidential": [
"false"
],
"inheritedRetentionRule": [
"ruleId_1"
],
"contentVersionsSize": [
"0.0"
],
"hasContent": [
"false"
],
"attachedPrincipalAncestorsIntIds": [
"-128",
"-69",
"-48",
"-4",
"200221"
],
"secondaryConceptsIntIds": [
"-155",
"-85"
],
"sameInactiveFateAsFolder": [
"true"
],
"published": [
"false"
],
"collection": [
"zeCollection"
],
"administrativeUnit": [
"unitId_12b"
],
"isCheckoutAlertSent": [
"false"
],
"folder": [
"B52"
],
"principalConceptsIntIds": [
"-128",
"-48",
"-4"
],
"category": [
"categoryId_X100"
],
"retentionRule": [
"ruleId_1"
],
"essential": [
"false"
]
},
"contentMetadatas": null
},
{
"id": "A42_numericContractWithDifferentCopy",
"schemaType": "document",
"metadatas": {
"sameSemiActiveFateAsFolder": [
"true"
],
"caption": [
"Crocodile / Crocodile - Document contrat numérique avec un autre exemplaire"
],
"visibleInTrees": [
"false"
],
"title": [
"Crocodile - Document contrat numérique avec un autre exemplaire"
],
"type": [
"documentTypeId_9"
],
"createdOn": [
"2023-09-27T13:07:43.975"
],
"content": [
"com.constellio.model.services.contents.ContentImpl@2c9ea756[checkoutDateTime=<null>,checkoutSource=0,checkoutUserId=<null>,currentCheckedOutVersion=<null>,currentVersion=com.constellio.model.entities.records.ContentVersion@2d7a6503[comment=<null>,contentVersionDataSummary=ContentVersionDataSummary{hash=GRVIJHXC4UR3Z6VNEJIJAG4RJZ7KVQYD, mimetype=application/vnd.openxmlformats-officedocument.wordprocessingml.document, length=37455},filename=contrat.docx,lastModificationDateTime=2023-09-27T13:07:43.551,lastModifiedBy=00000000006,version=0.1],dirty=false,emptyVersion=false,history=<null>,id=00000200310,lazyHistory=com.constellio.model.services.contents.ContentFactory$2@42ef282a]"
],
"principalpath": [
"/admUnits/unitId_10/unitId_10a/A42/A42_numericContractWithDifferentCopy"
],
"modifiedOn": [
"2023-09-27T13:07:43.975"
],
"estimatedSize": [
"4594"
],
"archivisticStatus": [
"SEMI_ACTIVE"
],
"currentContentSize": [
"37455.0"
],
"copyStatus": [
"PRINCIPAL"
],
"principalAncestorsIntIds": [
"-164",
"-74",
"-4"
],
"borrowed": [
"false"
],
"contentVersionsCount": [
"1"
],
"confidential": [
"false"
],
"inheritedRetentionRule": [
"ruleId_2"
],
"contentVersionsSize": [
"37455.0"
],
"secondaryConceptsIntIds": [
"-155",
"-108",
"-85"
],
"attachedPrincipalAncestorsIntIds": [
"-636",
"-164",
"-74",
"-4"
],
"hasContent": [
"true"
],
"sameInactiveFateAsFolder": [
"true"
],
"published": [
"false"
],
"collection": [
"zeCollection"
],
"administrativeUnit": [
"unitId_10a"
],
"isCheckoutAlertSent": [
"false"
],
"filename": [
"contrat.docx"
],
"folder": [
"A42"
],
"mimetype": [
"Microsoft Word"
],
"category": [
"categoryId_X110"
],
"principalConceptsIntIds": [
"-164",
"-4"
],
"retentionRule": [
"ruleId_2"
],
"essential": [
"false"
]
},
"contentMetadatas": null
},
{
"id": "A42_numericDocumentWithSameCopy",
"schemaType": "document",
"metadatas": {
"sameSemiActiveFateAsFolder": [
"true"
],
"visibleInTrees": [
"false"
],
"caption": [
"Crocodile / Crocodile - Document numérique avec le même exemplaire"
],
"title": [
"Crocodile - Document numérique avec le même exemplaire"
],
"createdOn": [
"2023-09-27T13:07:43.976"
],
"content": [
"com.constellio.model.services.contents.ContentImpl@1b129336[checkoutDateTime=<null>,checkoutSource=0,checkoutUserId=<null>,currentCheckedOutVersion=<null>,currentVersion=com.constellio.model.entities.records.ContentVersion@653ebf2a[comment=<null>,contentVersionDataSummary=ContentVersionDataSummary{hash=ADIMNNRL566Z6IL7KKIPN2BBKOVN7BA3, mimetype=application/vnd.openxmlformats-officedocument.wordprocessingml.document, length=31777},filename=proces.docx,lastModificationDateTime=2023-09-27T13:07:43.573,lastModifiedBy=00000000006,version=0.1],dirty=false,emptyVersion=false,history=<null>,id=00000200311,lazyHistory=com.constellio.model.services.contents.ContentFactory$2@33f1e48a]"
],
"principalpath": [
"/admUnits/unitId_10/unitId_10a/A42/A42_numericDocumentWithSameCopy"
],
"modifiedOn": [
"2023-09-27T13:07:43.976"
],
"estimatedSize": [
"4260"
],
"archivisticStatus": [
"SEMI_ACTIVE"
],
"currentContentSize": [
"31777.0"
],
"copyStatus": [
"PRINCIPAL"
],
"principalAncestorsIntIds": [
"-164",
"-74",
"-4"
],
"borrowed": [
"false"
],
"contentVersionsCount": [
"1"
],
"confidential": [
"false"
],
"inheritedRetentionRule": [
"ruleId_2"
],
"contentVersionsSize": [
"31777.0"
],
"secondaryConceptsIntIds": [
"-155",
"-108",
"-85"
],
"attachedPrincipalAncestorsIntIds": [
"-492",
"-164",
"-74",
"-4"
],
"hasContent": [
"true"
],
"sameInactiveFateAsFolder": [
"true"
],
"published": [
"false"
],
"collection": [
"zeCollection"
],
"administrativeUnit": [
"unitId_10a"
],
"isCheckoutAlertSent": [
"false"
],
"filename": [
"proces.docx"
],
"folder": [
"A42"
],
"mimetype": [
"Microsoft Word"
],
"category": [
"categoryId_X110"
],
"principalConceptsIntIds": [
"-164",
"-4"
],
"retentionRule": [
"ruleId_2"
],
"essential": [
"false"
]
},
"contentMetadatas": null
}
],
"facets": [
{
"facetId": "copyStatus_s",
"facetName": "Statut d'exemplaire",
"values": [
{
"id": "copyStatus_s:P",
"name": "Principal",
"count": 15
},
{
"id": "copyStatus_s:S",
"name": "Secondaire",
"count": 15
}
]
},
{
"facetId": "administrativeUnitId_s",
"facetName": "Unités administratives",
"values": [
{
"id": "administrativeUnitId_s:unitId_10a",
"name": " 10A - Unité 10-A",
"count": 14
},
{
"id": "administrativeUnitId_s:unitId_12b",
"name": " 12B - Unité 12-B",
"count": 1
}
]
},
{
"facetId": "schema_s",
"facetName": "Type",
"values": [
{
"id": "schema_s:document_default",
"name": "Document",
"count": 15
}
]
},
{
"facetId": "categoryId_s",
"facetName": "Catégories",
"values": [
{
"id": "categoryId_s:categoryId_X110",
"name": " X110 - X110",
"count": 8
},
{
"id": "categoryId_s:categoryId_Z120",
"name": " Z120 - Z120",
"count": 6
},
{
"id": "categoryId_s:categoryId_X100",
"name": " X100 - X100",
"count": 1
}
]
},
{
"facetId": "archivisticStatus_s",
"facetName": "Statut archivistique",
"values": [
{
"id": "archivisticStatus_s:d",
"name": "Détruit",
"count": 11
},
{
"id": "archivisticStatus_s:s",
"name": "Semi-actif",
"count": 4
}
]
}
],
"references": [
{
"id": "B52",
"schemaType": "folder",
"code": null,
"title": "Avocat",
"description": null
},
{
"id": "unitId_12b",
"schemaType": "administrativeUnit",
"code": "12B",
"title": "Unité 12-B",
"description": "Ze ultimate unit 12B"
},
{
"id": "categoryId_X100",
"schemaType": "category",
"code": "X100",
"title": "X100",
"description": "Ze category X100"
},
{
"id": "ruleId_1",
"schemaType": "retentionRule",
"code": "1",
"title": "Règle de conservation #1",
"description": "Description Rule 1"
},
{
"id": "documentTypeId_3",
"schemaType": "ddvDocumentType",
"code": "3",
"title": "Petit guide",
"description": null
},
{
"id": "A42",
"schemaType": "folder",
"code": null,
"title": "Crocodile",
"description": null
},
{
"id": "unitId_10a",
"schemaType": "administrativeUnit",
"code": "10A",
"title": "Unité 10-A",
"description": "Ze ultimate unit 10A"
},
{
"id": "categoryId_X110",
"schemaType": "category",
"code": "X110",
"title": "X110",
"description": "Ze category X110"
},
{
"id": "ruleId_2",
"schemaType": "retentionRule",
"code": "2",
"title": "Règle de conservation #2",
"description": null
},
{
"id": "documentTypeId_9",
"schemaType": "ddvDocumentType",
"code": "9",
"title": "Contrat",
"description": null
}
]
},
"highlights": null,
"nextRequest": {
"rows": 15,
"start": 3,
"end": 5,
"query": {
"searchTerms": "",
"collection": "zeCollection",
"schemaType": "document",
"filter": {
"and": [
{
"or": [
{
"metadata": "administrativeUnit",
"eq": "unitId_10"
},
{
"isTrue": "hasContent"
},
{
"metadata": "title",
"ctText": "guide"
}
]
},
{
"metadata": "openingDate",
"bt": {
"min": "2000-10-03",
"max": "2000-11-05"
}
},
{
"or": [
{
"metadata": "openingDate",
"gt": "2000-11-08"
},
{
"metadata": "title",
"startsWith": "Crocodile"
},
{
"isNotNull": "actualDestructionDate"
}
]
}
]
},
"searchParams": {
"resultCount": 3,
"startIndex": 3,
"hl": null,
"metadatas": "SUMMARY",
"facets": {
"computeFacets": true,
"facetMode": "SPECIFIC",
"selectedFacets": [
{
"metadata": "copyStatus",
"values": [
"P"
]
}
]
},
"corrector": false,
"showOnlyWriteAccess": false
},
"sorting": [
{
"metadata": "title",
"ascending": true
}
]
}
}
}