Finding Data Using Subjects, Predicates, and Objects

This topic provides information about using the find subcommand to find data in the Anzo system data source. The find subcommand includes options that enable you to retrieve statements that contain certain subjects, predicates, or objects.

Finding Statements with a Particular Subject

Use the -sub option to find statements whose subjects match the argument that you specify:

anzo find -sub argument

For example, the following command finds the statements whose subject is the URI for listing43068 in a fictional data set that captures sales activity where people buy and sell tickets for sporting events, shows, and concerts:

anzo find -sub http://a.com/abc/listing43068
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix datasource: <http://openanzo.org/datasource/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix anzo: <http://openanzo.org/ontologies/2008/07/Anzo#> .
@prefix ds: <http://cambridgesemantics.com/datasets/> .

<http://a.com/abc/listing43068> {
    <http://a.com/abc/listing43068> a <http://a.com/abc/listing> ;
    <http://a.com/abc/dateid> <http://a.com/abc/date2138> ;
    <http://a.com/abc/eventid> <http://a.com/abc/event2667> ;
    <http://a.com/abc/listtime> "2008-11-08T11:43:51.000Z"^^xsd:dateTime ;
    <http://a.com/abc/numtickets> "18"^^xsd:integer ;
    <http://a.com/abc/priceperticket> "129.0"^^xsd:double ;
    <http://a.com/abc/sellerid> <http://a.com/abc/person24148> ;
    <http://a.com/abc/totalprice> "2322.0"^^xsd:double .
}

<http://openanzo.org/metadataGraphs(http%3A%2F%2Fa.com%2Fabc%2Flisting43068)> {
    <http://a.com/abc/listing43068> a anzo:NamedGraph ;
    anzo:created "2017-06-07T19:35:56.419Z"^^xsd:dateTime ;
    anzo:createdBy <http://openanzo.org/system/internal/sysadmin> ;
    anzo:datasource datasource:systemDatasource ;
    anzo:hasMetadataGraph <http://openanzo.org/metadataGraphs(http%3A%2F%2Fa.com%2Fabc%2Flisting43068)> ;
    anzo:inheritsFrom ds:f2d1d13b-1a4c-4fe7-b3c4-a03038470771 ;
    anzo:lastModifiedByUser <http://openanzo.org/system/internal/sysadmin> ;
    anzo:modified "2017-06-07T19:35:56.419Z"^^xsd:dateTime ;
    anzo:persisted "true"^^xsd:boolean ;
    anzo:revision "0"^^xsd:long ;
    anzo:revisioned "false"^^xsd:boolean ;
    anzo:uuid <http://openanzo.org/namedGraphUUID/nonrevisioned/6b3300dc-6809-404c-a485-9217c0c8ceb4> .
}

Finding Statements with a Particular Object

Use the -uri option to find statements whose objects match the argument that you specify:

anzo find -uri argument

For example, the following command finds the statements whose object is the URI for listing43068:

anzo find -uri http://a.com/abc/listing43068
@prefix anzo: <http://openanzo.org/ontologies/2008/07/Anzo#> .
@prefix ds: <http://cambridgesemantics.com/datasets/> .

<http://a.com/abc/sales38630> {
    <http://a.com/abc/sales38630> <http://a.com/abc/listid> <http://a.com/abc/listing43068> .
}

ds:f2d1d13b-1a4c-4fe7-b3c4-a03038470771 {
    ds:f2d1d13b-1a4c-4fe7-b3c4-a03038470771 anzo:defaultNamedGraph <http://a.com/abc/listing43068> .
}

<http://openanzo.org/datasets#NamedGraphs> {
    <http://openanzo.org/datasets#NamedGraphs> anzo:namedGraph <http://a.com/abc/listing43068> .
}

Finding Statements with a Particular Predicate

Use the -pred option to find statements whose predicates match the argument that you specify:

anzo find -pred argument

Typically when you want to find statements that contain a predicate, it is helpful to use the -pred option in combination with -sub or -uri to find the intersection of statements that include the specified predicate and subject or object.

anzo find -pred argument1 [ -sub argument2 ] [ -uri argument3 ]

For example, the following command finds the statements for each person who is a friend of person 1. The example finds statements where the predicate is <http://a.com/abc/friend> and the subject is <http://a.com/abc/person1>:

anzo find -pred http://a.com/abc/friend -sub http://a.com/abc/person1
<http://a.com/abc/person1> {
<http://a.com/abc/person1> <http://a.com/abc/friend> <http://a.com/abc/person11549> ,
<http://a.com/abc/person11678> , <http://a.com/abc/person12081> ,
<http://a.com/abc/person12316> , <http://a.com/abc/person13199> ,
<http://a.com/abc/person13826> , <http://a.com/abc/person14472> ,
<http://a.com/abc/person1517> , <http://a.com/abc/person15410> ,
<http://a.com/abc/person1610> , <http://a.com/abc/person20018> ,
<http://a.com/abc/person20624> , <http://a.com/abc/person21998> ,
<http://a.com/abc/person2240> , <http://a.com/abc/person23101> ,
<http://a.com/abc/person26327> , <http://a.com/abc/person26733> ,
<http://a.com/abc/person27710> , <http://a.com/abc/person27835> ,
<http://a.com/abc/person28342> , <http://a.com/abc/person2894> ,
<http://a.com/abc/person29554> , <http://a.com/abc/person3005> ,
<http://a.com/abc/person30779> , <http://a.com/abc/person30798> ,
<http://a.com/abc/person31572> , <http://a.com/abc/person32204> ,
<http://a.com/abc/person32389> , <http://a.com/abc/person33618> ,
<http://a.com/abc/person36814> , <http://a.com/abc/person37192> ,
<http://a.com/abc/person39418> , <http://a.com/abc/person42897> ,
<http://a.com/abc/person43803> , <http://a.com/abc/person44537> ,
<http://a.com/abc/person44925> , <http://a.com/abc/person45422> ,
<http://a.com/abc/person47127> , <http://a.com/abc/person48078> ,
<http://a.com/abc/person7877> , <http://a.com/abc/person8052> ,
<http://a.com/abc/person9872> .
}