Collections

​In Memgraph Lab, the Collections feature allows you to organize and manage your Cypher queries efficiently by grouping them into named collections. This functionality is particularly useful for structuring queries related to specific projects, datasets, or analytical tasks, enhancing both organization and collaboration.​

With the collections feature, you get:

  • Organized query management: Group related queries together to streamline your workflow and quickly locate specific queries when needed.​

  • Enhanced collaboration: Share collections with team members, facilitating better collaboration and ensuring consistency across projects.​

  • Efficient query execution: Execute queries directly from their respective collections, reducing redundancy and improving productivity.​

Create and update a collection

To begin organizing your queries, you’ll first need to create a new collection.

To create a new collection, navigate to the Collections in Memgraph Lab and click on Create collection.

create-collection

Next, you will be prompted to directly add previously executed queries to the collection. You can skip this step and add your queries later.

add-query

To finish creating the collection, enter a meaningful Collection name that reflects the purpose or context of the queries it will contain.

collection-name

There are three main ways to add queries to a collection in Memgraph Lab, depending on where you are in the interface:

Every query is defined with its name (required) and description (optional).

edit-query

Add query from the Collections

If you’re managing collections directly, simply select a collection and click Add query to manually write and add a new query to the currently open collection.

Add query from the Query execution

After executing a query, you can save it directly to a collection.

add-to-collection

You can either choose an existing collection from the dropdown or create a new one on the spot by entering a name during the flow. You’ll also need to provide a query name before saving.

query-name-collections

Add query from the Run history

You can revisit previously executed queries and add them to a collection.

add-from-run-history

You can either choose an existing collection from the dropdown or create a new one on the spot by entering a name during the flow.

Importing and exporting collections

Query collections can be exported and imported as JSON files, making it easy to share across teams or back up your work.

collection-export

Sample collections

Memgraph Lab includes sample query collections loaded with datasets. These ready-to-use Cypher queries help users:

  • Quickly explore Memgraph features
  • Learn Cypher by example
  • Understand real-world use cases (e.g. fraud detection, recommendations, network analysis)

Each query within a sample collection includes description to explain functionality, making them easy to understand and adapt. Ideal for beginners, they reduce setup time and offer a hands-on way to explore graph data and practical applications.

Download a sample collection

After loading a dataset from the Datasets section, you can download the query collection containing the queries related to that dataset.

download-query-collection

For example, if you loaded the Game of Thrones dataset and downloaded the query collection, you will get the following queries:

got-collection-queries