Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added valid element names in for search conditions

...

Endpoint: http://localhost:8080/fcrepo/rest/fcr:search

Method: GET

Parameters: 

Name

Type

 

Used in condition

Currently implemented

condition

string

A condition consists of a metadata element name followed directly by an operator, followed directly by a value. 

Valid element names are

(TBD) 

: fedora_id, modified, created, content_size, mime_type, rdf_type

Valid operators are:  =, >, <, =>, <=

A search URI may specify one or more conditions

N

(tick)

fields

string

A comma separated list of fields to be returned in the search results

N

(tick)

max_results

int

Maximum number of results to return in a single “page”

N

(tick)

offset

int

The offset of the first result in the page.  The field is used in conjunction with max_results in order to present paged results.

N

(tick)

order_by

string

Field name to order the query by 

N

(tick)

order

string

asc or desc

N

(tick)

format

string

The format of the results. Valid values are: 

  • json
  • text
  • csv

N


modified

date string : Rfc 8601

The modification date: eg 2020-05-01T20:05:14+00:00

Y

(tick)

created

date string : Rfc 8601

The creation date: eg 2020-05-01T20:05:14+00:00

Y

(tick)

sha1

string

The SHA-1 of the resource

Y


md5

string

The MD5 of the resource

Y


rdf_type

string (URI)

The URI or abbreviated string representing the RDF type. Here are some examples: 

http://www.w3.org/ns/ldp#NonRDFSource

ldp:NonRDFSource

http://www.w3.org/ns/ldp#RDFSource

ldp:RDFSource

Y

(tick)

mime_type

string

The mimetype

Y

(tick)

fedora_id

string (URI)

The fedora resource ID*.  Given the resource http://localhost:8080/rest/resource1 ,  you may format this condition in the following three ways: 

fedora_id= resource1

fedora_id= /resource1

fedora_id= info:fedora/resource1

fedora_id= http://localhost:8080/rest/resource1

Y

(tick)

ocfl_id

string

The OCFL Object ID* 

Y

(tick)

content_size

int

The size of a resource in bytes

Y

(tick)

ancestor

URI

URI of the ancestral resource 

Y


ancestors

boolean

Used in conjunction with the fedora_id field. When set to true, display the ancestors

.Y

.

N


depthintIndicates the depth of recursive descendents query queries.  1 would indicate just the immediate  children, 2 grandchildren, 3 great-grandchildren, and so on.N

descendants

boolean

Used in conjunction with the fedora_id field. When set to true, display the descendants.

Y


*Supports the wild-card operator(*)

Anatomy of a Search Result (HTTP Response Body)

{

  input_params: {

    conditions: [“fedora_id=*”], 

    max_results: 10,

    ...

  },

  pagination: {

    max_results: 10,

    offset: 0, 

    ...  

  },

  results: [

   {

      “fedora_id”:  “http://localhost:8080/rest/resource1”,

      ...

    }, 

    {

      “fedora_id”:  “http://localhost:8080/rest/resource2”,

      ...

    }, 

    ...

  ]

}


Condition Parameter

A search query may specify one or more condition parameters.  A condition parameter consists of three parts:  field, operation, and value.  For example the condition "fedora_id is equal to /myresource" would translate to the following query parameter value:

fedora_id=/myresource where "fedora_id" is the field,  "=" is the operator and "/myresource" is the object.  If you specify more than one condition parameter,  the query parser will assume a logical AND operator  operator connects them.  So if you have the following  two conditions

      fedora_id=/myresource*

      mime_type=image/*

fedora Fedora will understand this to signify "all resources where the fedora id starts with /myresource and  and matching resources have any image/* mime-type.

Wild Cards

The star wild-card signifier (*) can be used in conditions for simple string matching.

...

GET http://localhost:8080/fcrepo/rest/fcr:search ?condition=fedora_id%3D*

List

...

grandchildren of resource x

Query param value:  ancestor=/resource1

GET http://localhost:8080/fcrepo/rest/fcr:search ?condition=ancestor%3Dfedora_id%3D/resource1&descendents=true&depth=2

List all ancestors of resource x

GET http://localhost:8080/fcrepo/rest/fcr:search ?condition=fedora_id%3D/my/fedora/resource1&conditionancestors=ancestors%3Dtruetrue

List

...

fedora id, mime_types for resources where content_size > 1 megabyte.

GET http://localhost:8080/fcrepo/rest/fcr:search ?condition=fedoracontent_id%3Dsize%3E/my/fedora/resource1&condition=descendants%3Dtrue&return_fields=fedora_id,mime_type

Return Body (JSON)

{

  ...

  [

  {

    “fedora_id”:  “http://localhost:8080/rest/resource1”,

    “mime_type”: “image/jpg”

  }, 

  {

    “fedora_id”:  “http://localhost:8080/rest//resource2”,

    “mime_type”: “text/plain”

  }, 

  ...

  ]

}