Skip to main content

Selecting a Specific Actor

Query By Id

Every subject in Fluree has a unique _id. This _id is a long integer (a large number), and it is automatically generated when that subject is created. It will never change, and it can never be changed.

You can use this id to query one specific subject.

For example, if you knew an actor's _id, you could select them using "from": that_id.

{
"select": ["*"],
"from": 4316442136599
}

Query By Unique Two-Tuple

An easier way to select a single subject is to specify any unique predicate and that predicate's object (value).

For example, in our movie ledger, the actor/name predicate is unique. We can select the actor Angelina Jolie with the following query:

{
"select": ["*"],
"from": ["actor/name", "Angelina Jolie"]
}

We have to use a unique predicate for this purpose. If we want to select Angelina Jolie, and we specified her gender, then that wouldn't allow us to uniquely identify her.

If you weren't sure whether a predicate was unique, you could query it using:

{
"select": ["_predicate/unique"],
"from": ["_predicate/name", "actor/name"]
}

Or, you could select all predicates:

{
"select": ["*"],
"from": "_predicate"
}

Can you select all predicates from the movie `Titanic` (using the `movie/title` predicate)?