Search
AthentoSE allows complex searches to be performed on the files found on the platform. To perform these searches, it is necessary to define a structure of groups and rules, which will define the filter to be applied on a set of files.
Searches can be performed on deleted or non-deleted documents using, for the search on deleted documents, the clause ecm:isTrashed
with value true
or 1
. In the instantiation of the search engine, it will be necessary to indicate the attribute (optional with default value False
) removed
in charge of internally discriminating.
Execution
user = User.objects.get(username="<username>") filters = { ... } fils.advanced_search(user, filters)
Filter structure
The structure of filters is the same as the one applied to search using the Django ORM.
The structure of a filter is composed of groups of rules unified by a conjunction and rules.
Example of a filter:
{ "AND": [ # Grupo inicial A (Conjunto de reglas unidas por la conjuncion "AND") { # Regla A1 en grupo A "type": "serie", "schema": { "value": ["123-123-213", "321-321-321"] } }, { # Regla A2 en grupo A "type": "doctype", "schema": { "value": ["123-123-123", "321-321-321"] } }, { # Regla A3 en grupo A (otro grupo, B) "AND": [ # Grupo B (Conjunto de reglas unidas por la conjunción "AND") { # Regla B1 "type": "metadata", "schema": { "uuid": "123-123-123", "value": ["myValueA", "myValueB"], "lookup_type": "contains", "negate": False } }, { # Regla B2 "type": "metadata", "schema": { "uuid": "321-321-321", "value": ["myValue2A", "myValue2B"], "lookup_type": "contains", "negate": False } }, { # Regla B3 en grupo B "OR": [ # Grupo C (Conjunto de reglas unidas por la conjunción "OR") { # Regla C1 "type": "metadata", "schema": { "uuid": "111-111-111", "value": ["myValue111A", "myValue111B"], "lookup_type": "contains", "negate": False } }, { # Regla C2 "type": "metadata", "schema": { "uuid": "222-222-222", "value": ["myValue222A", "myValue222B"], "lookup_type": "contains", "negate": False } } ] } ] } ] }
Groups
Groups are a set of rules joined by a conjunction. Conjunctions can be AND
or OR
.
In the filter example above, we can find three groups (A, B and C).
Group A:
This is the initial group containing all the rules.
Whenever more than one rule exists, a group applies.
Group B:
Group B is a set of "AND" rules, which also contains a rule that is Group C.
{ "AND": [ # Grupo B (Conjunto de reglas unidas por la conjunción "AND") { # Regla B1 "type": "metadata", "schema": { "uuid": "123-123-123", "value": ["myValueA", "myValueB"], "lookup_type": "contains", "negate": False } }, { # Regla B2 "type": "metadata", "schema": { "uuid": "321-321-321", "value": ["myValue2A", "myValue2B"], "lookup_type": "contains", "negate": False } }, { # Regla B3 en grupo B "OR": [ # Grupo C (Conjunto de reglas unidas por la conjunción "OR") { # Regla C1 "type": "metadata", "schema": { "uuid": "111-111-111", "value": ["myValue111A", "myValue111B"], "lookup_type": "contains", "negate": False } }, { # Regla C2 "type": "metadata", "schema": { "uuid": "222-222-222", "value": ["myValue222A", "myValue222B"], "lookup_type": "contains", "negate": False } } ] } ] }
Group C:
Group C is a set of "OR" rules:
{ "OR": [ # Grupo C (Conjunto de reglas unidas por la conjunción "OR") { # Regla C1 "type": "metadato", "schema": { "uuid": "111-111-111", "value": ["myValue111A", "myValue111B"], "lookup_type": "contains", "negate": False } }, { # Regla C2 "type": "metadato", "schema": { "uuid": "222-222-222", "value": ["myValue222A", "myValue222B"], "lookup_type": "contains", "negate": False } } ] }
Rules
A rule is a key/value dictionary, which will be used to define the filter. There are many types of rules with different configurations:
ORM filters
Filter by series
The filter by series allows filtering by one series or multiple series.
{"type": "serie", "schema": {"value": ["123-123-213", "321-321-321"]}}
Donde:
key | Value |
---|---|
type | serie |
schema[value] | List of UUIDs, either for single or multiple UUIDs. In the case of multiple, a OR |
Ejemplo:
{"type": "serie", "schema": {"value": ["87c217f9-03b4-499b-979f-e56f0b228b7c"]}} { "type": "serie", "schema": { "value": ["87c217f9-03b4-499b-979f-e56f0b228b7c", "656ccfc3-cd14-422b-9a61-ac051e740824"] } }
Filter by document type
The filter by document type allows you to filter by one or multiple document types.
{"type": "doctype", "schema": {"value": ["123-123-123", "321-321-321"]}}
Where:
key | Value |
---|---|
type | serie |
schema[value] | List of UUIDs, either for single or multiple UUIDs. In the case of multiple, a OR |
Example:
{"type": "doctype", "schema": {"value": ["8a066e45-da4f-45fc-9bf0-9686f616ea5f"]}} { "type": "doctype", "schema": { "value": ["8a066e45-da4f-45fc-9bf0-9686f616ea5f", "9686f616ea5f-da4f-45fc-9bf0-9686f616ea5f-8a066e45"] } }
Filter by UUID
The UUID filter allows you to filter directly by the UUID of a single or multiple documents.
{"type": "uuid", "schema": {"value": ["f9f343d2-d419-4819-906f-03d7acdc3695"]}}
Where:
key | Value |
---|---|
type | serie |
schema[value] | List of UUIDs, either for single or multiple UUIDs. In the case of multiple, a OR |
Example:
{"type": "uuid", "schema": {"value": ["f9f343d2-d419-4819-906f-03d7acdc3695"]}} { "type": "uuid", "schema": { "value": ["f9f343d2-d419-4819-906f-03d7acdc3695", "9467552f-affb-473c-99d9-348ee0a6cecb"] } }
Filter by author
Filter by Author, allows you to filter directly by the uuid
of a user or multiple users.
{"type": "author", "schema": {"value": ["user1-uuid", "user2-uuid"]}}
Donde:
key | Value |
---|---|
type | serie |
schema[value] | List of uuid , for both single and multiple authors. In the case of multiple, a OR |
Example:
{"type": "author", "schema": {"value": ["123-321-123"]}} { "type": "author", "schema": { "value": ["123-321-123, 345-543-345"] } }
Filter by document status
The filter by document status allows you to filter directly by one or multiple document statuses.
{"type": "state", "schema": {"value": ["pending"]}}
Where:
key | Value |
---|---|
type | serie |
schema[value] | List of state , for either single or multiple states. In the case of multiple, a OR |
Example:
{"type": "state", "schema": {"value": ["pending"]}} { "type": "author", "schema": { "value": ["pending", "finished"] } }
Filtering by document lifecycle status
Filtering by document lifecycle status allows you to filter directly by one or multiple document lifecycle statuses.
{"type": "lifecycle_state", "schema": {"value": ["123-123-123"]}}
Where:
key | Value |
---|---|
type | serie |
schema[value] | List of UUIDs of lifecycle states, either for single or multiple states. In the case of multiple, a OR |
Example:
{"type": "lifecycle_state", "schema": {"value": ["087444a6-6de2-4d4c-8a45-f471684542bc"]}} { "type": "lifecycle_state", "schema": { "value": ["087444a6-6de2-4d4c-8a45-f471684542bc", "843dfd69-57a0-49ad-99e2-b3c2d177a357"] } }
Filter by creation date
The filter by creation date, allows you to filter using an operator, an expression or a value (date).
OPERATOR
{"type": "creation_date", "schema": {"value": "22-4-2020", "condition": "<"}}
Where:
Key | Value |
---|---|
type | creation_date |
date | Date to filter by |
operator | Operator to be applied to perform filtering ('<', '<=', '==', 'LIKE', '>=', '>' ) |
EXPRESSION
{"type": "creation_date", "schema": {"condition": "last_day", "value": 2}}
Where:
key | Value |
---|---|
type | creation_date |
schema[condition] | Expression to filter by ( 'current_month', 'current_year', 'current_day', 'last_month', 'last_year', 'last_day' ) |
schema[value] | Remaining value as delta to be applied in cases of last_* ('last_month', 'last_year', 'last_day' ) |
RANGE
{"type": "creation_date", "schema":{"condition": "range", "start_date": "21-04-2020", "end_date": "23-04-2020"}}
Where:
key | Value |
---|---|
type | creation_date |
schema[conditon] | range |
schema[start_date] | Start date in the range |
schema[end_date] | End date in range |
Filter by modification date
The filter by modification date, allows you to filter using an operator, an expression or a value (date).
OPERATOR
{"type": "modification_date", "schema": {"condition": ">", "value": "10-10-1010"}}
Where:
key | Value |
---|---|
type | modification_date |
schema[conditon] | Operator to be applied to perform filtering ( '<', '<=', '==', 'LIKE', '>=', '>' ) |
schema[value] | Date to filter by |
EXPRESSION
{"type": "modification_date", "schema": {"condition": "last_day", "value": 2}}
Where:
key | Value |
---|---|
type | modification_date |
schema[conditon] | Expression by which to filter ( 'current_month', 'current_year', 'current_day', 'last_month', 'last_year', 'last_day' ) |
schema[value] | Remaining value as delta to be applied in cases of last_* ('last_month', 'last_year', 'last_day' ) |
RANGE
{"type": "modification_date", "schema":{"condition": "range", "start_date": "21-04-2020", "end_date": "23-04-2020"}}
Where:
key | Value |
---|---|
type | modification_date |
schema[conditon] | range |
schema[start_date] | Start date of the range |
schema[end_date] | End date of the range |
Filter by number of pages
The filter by number of pages allows you to filter directly by number or by a range.
{"type": "num_pages", "schema": {"condition": ">", "value": 10}}
Where:
key | Value |
---|---|
type | num_pages |
schema[conditon] | Operator to be applied to perform filtering ('<', '<=', '==', 'LIKE', '>=', '>' ) |
schema[value] | Number pages |
RANGE
{"type": "num_pages", "schema": {"condition": "range", "start_number": 2, "end_number": 10}}
Where:
key | Value |
---|---|
type | num_pages |
schema[condition] | range |
schema[start_number] | Range start page number |
schema[end_number] | Range end page number |
Filter by filename
Filter by filename, allows filtering by filename content, exact, insensitive, etc.
{"type": "filename", "schema": {"value": "Mi fichero", "lookup_type": "contains"}}
Where:
key | Value |
---|---|
type | filename |
schema[value] | Value for which to search |
schema[lookup_type] | Form in which to search the chain ('exact', 'iexact', 'contains', 'icontains', 'startswith', 'istartswith', 'endswith', 'iendswith' ) |
Filter globally
The global filter allows you to perform a global search, which is a search on filename or metadata value (text).
{"type": "text", "schema": {"value": "Campo1"}}
Where:
key | Value |
---|---|
type | text |
schema[value] | Value for which to search |
Filtar por tipo de "source"
El filtrado por tipo de "source", nos permite filtrar ficheros en base a como fue su creación.
{"type": "source", "schema": {"value": "public_web"}}
Donde:
key | Value |
---|---|
type | source |
schema[value] | Valor por el cual buscar. Ver la variable SOURCE_TYPES |
Filtar por extension
{"type": "extension", "schema": {"value": "pdf"}}
Donde:
key | Value |
---|---|
type | extension |
schema[value] | Value for which to search |
Filtering by metadata
Filtering by metadata allows us to filter by the value contained in a metadata. Metadata can be of different types. Therefore there are multiple ways of filtering.
THE METADATA HAS OR HAS NOT VALUE
Allows us to filter by metadata with or without value.
{"type": "metadata", "schema": {"uuid": "123-123-123", "value":""}}
Where:
key | Value |
---|---|
type | source |
schema[value] | "" (string vacio) to filter by metadata with no value |
schema[uuid] | UUID of the metadata type defining the metadata |
Example:
{"type": "metadata", "schema": {"uuid": "8ea1da32-883c-4f5b-8d98-efa9e2d302ef", "value": ""}}
TEXT TYPE METADATA
Filter by the value of a text type metadata.
{"type": "metadata", "schema": {"uuid": "123-123-123", "value": ["myValueA", "myValueB"], "lookup_type": "contains"}}
Where:
key | Value |
---|---|
type | metadata |
schema[value] | List of values, either for single or multiple values. In the case of multiple, a OR |
schema[uuid] | UUID of the metadata type defining the metadata |
schema[lookup_type] | Form in which to search the chain ('exact', 'iexact', 'contains', 'icontains', 'startswith', 'istartswith', 'endswith', 'iendswith' ) |
Example:
{"type": "metadata", "schema": {"uuid": "df8a0cf4-3a47-4649-a2d4-aaaded3af6e8", "value": ["Campo11"], "lookup_type": "exact"}}
DATE TYPE METADATA
The filter by metadata of type date, allows filtering using an operator, an expression or a value (date).
- Operator
{"type": "metadata", "schema": {"uuid": "123-123-123", "condition": ">=", "value": "23-04-2020"}}
Where:
key | Value |
---|---|
type | metadata |
schema[value] | Date by which it will be filtered |
schema[uuid] | UUID of the metadata type defining the metadata |
schema[condition] | Operator to be applied to perform filtering ('<', '<=', '==', 'LIKE', '>=', '>' ) |
Example:
{"type": "metadata", "schema": {"uuid": "70f5fb51-392c-44bd-abe4-869260ab3d20", "condition": "==", "value": "23-04-2020"}} {"type": "metadata", "schema": {"uuid": "8ea1da32-883c-4f5b-8d98-efa9e2d302ef", "condition": "==", "value": "21-04-2020 13:00:00"}}
- Expression
{"type": "metadata", "schema": {"uuid": "123-123-123", "condition": "last_day", "value": 1}}
Where:
key | Value |
---|---|
type | metadata |
schema[value] | Remaining value as delta to be applied in cases of last_* ('last_month', 'last_year', 'last_day' ) |
schema[uuid] | UUID of the metadata type defining the metadata |
schema[condition] | Expression by which to filter ('current_month', 'current_year', 'current_day', 'last_month', 'last_year', 'last_day' ) |
Example:
{"type": "metadata", "schema": {"uuid": "70f5fb51-392c-44bd-abe4-869260ab3d20", "condition": "last_day", "value": 1}}
- Range
{"type": "metadata", "schema": {"uuid": "123-123-123", "condition": "range", "start_date": "23-04-2020", "end_date": "25-04-2020"}}
Where:
key | Value |
---|---|
type | metadata |
schema[start_date] | Start date in the range |
schema[end_date] | End date in the range |
schema[uuid] | UUID of the metadata type defining the metadata |
schema[condition] | range |
FILE TYPE METADATA (NOT IMPLEMENTED.)
Allows filtering of file type metadata, by the value of a file UUID.
{"type": "metadata", "schema": {"uuid": "123-123-123", "value": ["111-222-333"]}}
Where:
key | Value |
---|---|
type | metadata |
schema[value] | List of UUIDs of files, either for single or multiple UUIDs. In the case of multiple, a OR |
schema[uuid] | UUID of the metadata type defining the metadata |
Example:
{"type": "metadata", "schema": {"uuid": "4c76c07b-ddd0-48f8-bf1e-424cfc2be647", "value": ["0abee75b-29ed-45e9-a6a9-2d1452c47412"]}}
CHOICE OR MASTERTABLE METADATA
Ehis filter allows filtering by the value of a choice or mastertable metadata type
{"type": "metadata", "schema": {"uuid": "123-123-123", "value": ["01", "02"], "lookup_type": "exact"}}
Where:
key | Value |
---|---|
type | metadata |
schema[value] | List of values (keys), either for single or multiple values. In the case of multiple, a OR |
schema[uuid] | UUID of the metadata type defining the metadata |
schema[look_type] | Form in which to search the chain ('exact', 'iexact', 'contains', 'icontains', 'startswith', 'istartswith', 'endswith', 'iendswith' ) |
Example:
{"type": "metadata", "schema": {"uuid": "e4e477de-e636-48fa-aafd-3541258d835a", "value": ["0001", "0513"], "lookup_type": "exact"}}
USER TYPE METADATA
Allows filtering by metadata that is of user type.
{"type": "metadata", "schema": {"uuid": "123-123-123", "value": ["username1", "username2"]}}
Where:
key | Value |
---|---|
type | metadata |
schema[value] | List of usernames , for either single or multiple values. In the case of a multiple, a OR |
schema[uuid] | UUID of the metadata type defining the metadata |
Example:
{"type": "metadata", "schema": {"uuid": "123-123-123", "value": ["mrp@athento.com", "ari@athento.com"]}}
METADATA OF TYPE GROUP (NOT IMPLEMENTED.)
Allows filtering by group type metadata.
{"type": "metadata", "schema": {"uuid": "123-123-123", "value": ["111-222-333", "333-222-111"]}}
Where:
key | Value |
---|---|
type | metadata |
schema[value] | List of UUIDs, either for single or multiple UUIDs. In the case of multiple, a OR |
schema[uuid] | UUID of the metadata type defining the metadata |
Example:
{"type": "metadata", "schema": {"uuid": "65642352-c50f-4726-91b1-085908022944", "value": ["1d3d57f6-bf3c-4a58-9ce7-c3b18e08f792", "a1887603-affc-4a88-98ba-b23cacd1ca1d"]}}METADATA OF TYPE NUMBER
METADATA OF TYPE NUMBER
Allows filtering by metadata of type number.
{"type": "metadata", "schema": {"uuid": "123-123-123", "value": 1000, "condition": ">="}}
Where:
key | Value |
---|---|
type | metadata |
schema[value] | List of UUIDs, either for single or multiple UUIDs. In the case of multiple, a OR |
schema[uuid] | UUID of the metadata type defining the metadata |
schema[condition] | This is the operator that sets the filtering condition |
Example:
{"type": "metadata", "schema": {"uuid": "65642352-c50f-4726-91b1-085908022944", "value": 1000, "condition": ">="}}
Comments
0 comments
Please sign in to leave a comment.