Index Creation on MongoDB ontologies
As all you know, the ontology isolates from the underlying Database.
Nonetheless, sometimes it is necessary for the architect of the solution built on the platform to access the underlying database to perform certain optimizations, and this is the case of indexes.
When you use MongoDB as the underlying database, if you have a significant volume of data, it is important to index the collection associated with the Ontology. This can be done from the QueryTool in the Control Panel.
See the Ontology indexes
From QueryTool, select NATIVE and specify db.<Nombre_Ontologia>.getIndexes()
If you run it on the HelsinkiPopulation ontology, you can see the index information. as you can see, you only have one index:
Create a new index on the Ontology
The platform automatically creates an index by _id and a geospatial index for geographic data, I can create new indexes using Mongo's createIndex method (https://docs.mongodb.com/manual/reference/method/db.collection.createIndex/)
If you am the ontology's owner or you have an ADMINISTRATOR Role, you can create an index from the QueryTool, for example:
db.<Nombre_Ontologia>.createIndex( { '<nombre_atributo>': 1 } ) --> crea índice ascendente sobre el atributo <nombre_atributo>
db.<Nombre_Ontologia>.createIndex( { '<nombre_atributo>': -1 } ) --> crea índice descendente sobre el atributo <nombre_atributo>
db.<Nombre_Ontologia>.( { '<nombre_atributo1>': 1, <nombre_atributo2>: -1 } ) --> crea índice compuesto sobre los 2 atributos
For your HelsinkiPopulation ontology that looks like this:
you can do this:
db.HelsinkiPopulation.createIndex({'Helsinki.year':1}) --> create ascending index on the Helsinki.year attribute
and if you check the indexes again, you can see that now you have 2 indexes: