Items and item sets¶
The item:* and item-set:* commands list, search, export and import items and item sets. The
media:* commands add media to items.
Exports are portable JSON-LD: one resource per file, which you can import into another installation. This is how you seed a demo or test installation with content that you curated on another one. See Export items for what the format keeps.
List and search items¶
+----+-------------------------+-------------------+----------+----------+-------+--------+
| Id | Title | Class | Template | ItemSets | Media | Public |
+----+-------------------------+-------------------+----------+----------+-------+--------+
| 1 | Mona Lisa | dctype:StillImage | | 1 | 1 | yes |
| 2 | Study for the Mona Lisa | | | 0 | 0 | yes |
+----+-------------------------+-------------------+----------+----------+-------+--------+
The command shows 50 items at a time; use --limit and --page for more. Filter by resource class,
resource template, item set, site, or exact property value (--property, -p, repeatable):
--public and --private filter on visibility, and --query passes any other Omeka S API search
parameter, such as --query "sort_by=title&sort_order=desc".
item:search searches the text of all properties, with the same filters:
item-set:list and item-set:search do the same for item sets. --json and --csv give the data for
scripts.
Export items¶
item:export takes item ids, or the same filters as item:list. One item is printed:
id=$(omeka-s-cli item:list --property dcterms:identifier=obj-2 --json | jq '.[0].id')
omeka-s-cli item:export "$id" --reference-by dcterms:identifier
{
"@context": {
"dcterms": "http://purl.org/dc/terms/",
"o": "http://omeka.org/s/vocabs/o#",
"o-ref": "https://omeka-s-contrib.github.io/omeka-s-ref/ns#"
},
"@type": "o:Item",
"o-ref:id": {
"dcterms:identifier": "obj-2"
},
"o:title": "Study for the Mona Lisa",
"o:is_public": true,
"dcterms:title": [
{
"type": "literal",
"is_public": true,
"@value": "Study for the Mona Lisa"
}
],
"dcterms:identifier": [
{
"type": "literal",
"is_public": true,
"@value": "obj-2"
}
],
"dcterms:relation": [
{
"type": "resource:item",
"is_public": true,
"o-ref:ref": {
"dcterms:identifier": "obj-1"
}
}
]
}
Several items go to a directory, one file each (<id>-<title>.jsonld); --output writes one item to a
file:
omeka-s-cli item:export --class dctype:StillImage --output-dir ~/export --reference-by dcterms:identifier
The export is Omeka S's JSON-LD, made portable:
- The
@contextis written into the file. - Everything that only means something on this installation is left out: ids, owner, dates,
property_id, thumbnails. - References use names instead of ids: the class term, the template label, the site slug.
- Item sets and linked items are written as
o-ref:ref, and the item itself gets ano-ref:id, both with the property you choose with--reference-by(defaultdcterms:title). Choose a property whose values are unique, such as an identifier. A record without a value for it is reported, and its link is left out.
Media and data from modules (such as the Mapping module) are not exported; the command lists what it left out. Warnings go to standard error when the export goes to standard output, so you can redirect or pipe it.
item-set:export exports item sets the same way:
Import an item set¶
item-set:import creates an item set from a JSON-LD file or URL that holds one item set:
~/content/paintings.jsonld
{
"@context": {
"dcterms": "http://purl.org/dc/terms/",
"dctype": "http://purl.org/dc/dcmitype/",
"o": "http://omeka.org/s/vocabs/o#",
"o-ref": "https://omeka-s-contrib.github.io/omeka-s-ref/ns#"
},
"@type": "o:ItemSet",
"o-ref:id": {"dcterms:identifier": "set-paintings"},
"o:title": "Paintings",
"o:is_public": true,
"o:is_open": true,
"dcterms:title": [{"type": "literal", "is_public": true, "@value": "Paintings"}],
"dcterms:identifier": [{"type": "literal", "is_public": true, "@value": "set-paintings"}]
}
Import the item sets before the items that belong to them.
Import an item¶
item:import creates an item from a JSON-LD file or URL that holds one item. Add media with --media
(-m), as ingester=source, once per media:
~/content/mona-lisa.jsonld
{
"@context": {
"dcterms": "http://purl.org/dc/terms/",
"dctype": "http://purl.org/dc/dcmitype/",
"o": "http://omeka.org/s/vocabs/o#",
"o-ref": "https://omeka-s-contrib.github.io/omeka-s-ref/ns#"
},
"@type": ["o:Item", "dctype:StillImage"],
"o-ref:id": {"dcterms:identifier": "obj-1"},
"o:title": "Mona Lisa",
"o:is_public": true,
"o:resource_class": {"o:term": "dctype:StillImage"},
"o:item_set": [{"o-ref:ref": {"dcterms:identifier": "set-paintings"}}],
"dcterms:title": [{"type": "literal", "is_public": true, "@value": "Mona Lisa"}],
"dcterms:creator": [{"type": "literal", "is_public": true, "@value": "Leonardo da Vinci"}],
"dcterms:identifier": [{"type": "literal", "is_public": true, "@value": "obj-1"}],
"dcterms:source": [{"type": "uri", "is_public": true, "@id": "https://en.wikipedia.org/wiki/Mona_Lisa", "o:label": "Wikipedia"}]
}
The upload ingester takes a local path or a URL. The other ingesters take what Omeka S expects: a URL
for url, iiif, iiif_presentation, oembed and youtube, and HTML for html. The item and its
media are created together: if Omeka S rejects a media file (for example, an extension that is not
allowed), the item is not created either.
--site (-s, repeatable) assigns the item to a site, by slug or title, instead of the sites in the
file. When none of the names matches a site, the item goes to the default site. Without --site, the
file's o:site applies. Without either (or without a default site), Omeka S adds the item to every
site that takes new items. Put --site after the file: it takes several values.
Options for a media follow its source, separated by ;: title, altText, public, a property
term such as dcterms:description, or anything else the ingester takes, such as YouTube's start (see
Add media to an item). Write a ; inside a value as \;. A --media value
can also be a JSON media object.
omeka-s-cli item:import ~/content/lecture.jsonld \
--media 'youtube=https://www.youtube.com/watch?v=dQw4w9WgXcQ;start=30;title=Recording'
References in the file are resolved on the installation you import into:
o:item_setand links to other items ("o-ref:ref": {"dcterms:identifier": "obj-1"}) name a property and a value. Import the records they point to first.o:resource_classis a term ando:resource_templatea label.- Properties are matched by vocabulary namespace, so a file may use another prefix than the installation does.
A reference that matches nothing, or more than one record, is an error: the import fails and the item
is not created, so it never loses a link without notice. Two items that link to each other (for
example dcterms:hasPart and dcterms:isPartOf) cannot both be imported as exported: the first one's
link has nothing to point to yet. Keep the link only in the file you import second. An item that
already exists is skipped, even when its file has such a problem.
Import with a configuration file¶
To import an item with several media, or to keep an import repeatable, describe it in a JSON file and
pass it with --config. Relative paths in it are relative to the file. It takes the JSON-LD source,
the item's sites, and its media as media objects; the title is only used
in messages:
~/content/portrait.import.json
{
"source": "portrait.jsonld",
"title": "Portrait of a woman",
"sites": ["collections"],
"media": [
{ "ingester": "upload", "source": "mona-lisa.png", "title": "Front", "altText": "A woman, half-length" },
{ "ingester": "iiif",
"source": "https://iiif.io/api/image/3.0/example/reference/918ecd18c2592080851777620de9bcb5-gottingen/info.json" }
]
}
Without a source, the file creates an item from a title alone (its dcterms:title), with its
itemSets (by title), sites and media. Any other property needs a JSON-LD file:
~/content/notebook.import.json
--site can't be combined with a configuration file: put the sites in the file. A configuration file
has the same shape as a blueprint's x-omeka-s-cli.items entry, see
Content.
Import without creating duplicates¶
Before creating a resource, item:import looks for it on the installation: by its o-ref:id (a property
and a value, written by item:export), else by its title. When it exists, the command changes nothing,
prints a notice and exits with code 0. So you can run the same import again:
A resource with neither an o-ref:id nor a title cannot be matched: it is created on every import, and
the command warns about it.
--dry-run reports what would happen without creating anything. --identify-by <term> matches on
another property of the file, and --json prints the result (created, exists, ambiguous or
would create) as JSON.
When an import fails¶
The command checks what Omeka S cannot handle on its own, and reports every problem of the file at once. Nothing is created:
if ! omeka-s-cli item:import ~/content/letter.jsonld; then
echo "Install what is missing, then import again." >&2
fi
letter.jsonld: property "letters:recipient" uses vocabulary https://example.org/ns/letters#, which is not installed (vocabulary:import)
letter.jsonld: property "dcterms:date": data type "numeric:timestamp" is not available (install the NumericDataTypes module)
~/content/letter.jsonld
{
"@context": {
"dcterms": "http://purl.org/dc/terms/",
"letters": "https://example.org/ns/letters#"
},
"@type": "o:Item",
"o:title": "Letter to Ludovico Sforza",
"dcterms:title": [{"type": "literal", "@value": "Letter to Ludovico Sforza"}],
"letters:recipient": [{"type": "literal", "@value": "Ludovico Sforza"}],
"dcterms:date": [{"type": "numeric:timestamp", "@value": "1482"}]
}
Install the vocabulary (see Vocabularies) or the module (see Modules) and import again. Omeka S checks the rest itself, such as the properties a resource template requires.
Add media to an item¶
media:ingesters lists the ways media can be added on the installation:
+-------------------+-------------------+
| Name | Label |
+-------------------+-------------------+
| upload | Upload |
| url | URL |
| html | HTML |
| iiif | IIIF image |
| iiif_presentation | IIIF presentation |
| oembed | oEmbed |
| youtube | YouTube |
+-------------------+-------------------+
media:add adds one media to an existing item. --source is what the ingester ingests; --title and
--alt-text are optional. The same source works for every core ingester:
| Ingester | source |
Other keys |
|---|---|---|
upload |
a local path or a URL; the file is stored | |
url |
the URL of a file; Omeka S downloads and stores it | store_original |
html |
the HTML | |
iiif |
the info.json URL of an IIIF image |
|
iiif_presentation |
the URL of an IIIF manifest | |
oembed |
the URL of a page from a provider Omeka S allows (YouTube, Vimeo, Flickr, ...) | |
youtube |
a https://www.youtube.com/watch?v=... or https://youtu.be/... URL |
start, end (seconds) |
url, iiif, iiif_presentation, oembed and youtube fetch from the internet when the media is
added.
What an ingester takes can't be predicted, especially for ingesters added by modules. Give the media as
a JSON object with --data, or in a file with --json-file:
omeka-s-cli media:add "$id" --data '{
"ingester": "youtube",
"source": "https://youtu.be/dQw4w9WgXcQ",
"start": "30",
"title": "Recording",
"dcterms:description": "The first minute of the talk"
}'
ingesteris required.sourcegoes where the ingester reads it:ingest_sourceforupload,ingest_urlforurl,htmlforhtml,o:sourcefor any other ingester.title,altTextandpublicset the media'sdcterms:title,o:alt_textando:is_public.- A property term (
dcterms:description) takes a string, a list of strings or JSON-LD values. - Every other key is passed to the ingester unchanged, for example YouTube's
startandend, or a module ingester's own key. A raw key such aso:sourcewins over a mapped one.
The flags (--ingester, --source, --title, --alt-text) are shortcuts and override the JSON. With
--json-file, a relative upload source is relative to the file. The same media objects go in an
item:import configuration file and in --media.
Reference¶
All commands also accept the global options.
item:list¶
List items
| Option | Description | Default |
|---|---|---|
--class <value> |
Resource class term, e.g. dctype:StillImage | |
--template <value> |
Resource template label | |
--item-set <value> |
Item set ID | |
--site <value> |
Site slug or title | |
-p, --property [filter...] |
Exact property value as term=value, e.g. dcterms:creator=Leonardo (repeatable) | |
--public |
Only public resources | |
--private |
Only private resources | |
--query <value> |
Extra Omeka API query string, e.g. "sort_by=title&sort_order=desc" | |
--limit <value> |
Maximum number of results (default: 50) | |
--page <value> |
Page of results to show (with --limit) | |
-j, --json |
Output json | |
-c, --csv |
Output csv |
item:search¶
Search items by text
| Argument | Description | Default |
|---|---|---|
<text> |
Text to search for in all properties (fulltext search) |
| Option | Description | Default |
|---|---|---|
--class <value> |
Resource class term, e.g. dctype:StillImage | |
--template <value> |
Resource template label | |
--item-set <value> |
Item set ID | |
--site <value> |
Site slug or title | |
-p, --property [filter...] |
Exact property value as term=value, e.g. dcterms:creator=Leonardo (repeatable) | |
--public |
Only public resources | |
--private |
Only private resources | |
--query <value> |
Extra Omeka API query string, e.g. "sort_by=title&sort_order=desc" | |
--limit <value> |
Maximum number of results (default: 50) | |
--page <value> |
Page of results to show (with --limit) | |
-j, --json |
Output json | |
-c, --csv |
Output csv |
item:export¶
Export items as portable JSON-LD
| Argument | Description | Default |
|---|---|---|
[ids...] |
IDs of the items to export (default: all that match the filters) |
| Option | Description | Default |
|---|---|---|
--class <value> |
Resource class term, e.g. dctype:StillImage | |
--template <value> |
Resource template label | |
--item-set <value> |
Item set ID | |
--site <value> |
Site slug or title | |
-p, --property [filter...] |
Exact property value as term=value, e.g. dcterms:creator=Leonardo (repeatable) | |
--public |
Only public resources | |
--private |
Only private resources | |
--query <value> |
Extra Omeka API query string, e.g. "sort_by=title&sort_order=desc" | |
-o, --output <value> |
File to write one exported resource to (default: standard output) | |
--output-dir <value> |
Directory to write one file per resource to | |
--reference-by <value> |
Property that identifies records in references and in the o-ref:id of each resource (default: dcterms:title) |
item:import¶
Import one item from a JSON-LD file or URL
| Argument | Description | Default |
|---|---|---|
[source] |
JSON-LD file or URL holding one item |
| Option | Description | Default |
|---|---|---|
--config <value> |
JSON file or URL describing the import: {"source", "title", "sites", "media"} or, without a source, {"title", "itemSets", "sites", "media"} | |
-m, --media [spec...] |
Media to attach, as ingester=source[;key=value...] (e.g. upload=./photo.jpg;title=Front or youtube=https://youtu.be/ID;start=30) or a JSON media object (repeatable) | |
-s, --site [slug...] |
Site (slug or title) to assign the item to, replacing the file's o:site; no match → the default site (repeatable) | |
--identify-by <value> |
Property whose value identifies an existing item (default: the file's o-ref:id, else the title) | |
--dry-run |
Report what would be done, without doing it | |
-j, --json |
Output json |
item-set:list¶
List item sets
| Option | Description | Default |
|---|---|---|
--class <value> |
Resource class term, e.g. dctype:StillImage | |
--template <value> |
Resource template label | |
--site <value> |
Site slug or title | |
-p, --property [filter...] |
Exact property value as term=value, e.g. dcterms:creator=Leonardo (repeatable) | |
--public |
Only public resources | |
--private |
Only private resources | |
--query <value> |
Extra Omeka API query string, e.g. "sort_by=title&sort_order=desc" | |
--limit <value> |
Maximum number of results (default: 50) | |
--page <value> |
Page of results to show (with --limit) | |
-j, --json |
Output json | |
-c, --csv |
Output csv |
item-set:search¶
Search item sets by text
| Argument | Description | Default |
|---|---|---|
<text> |
Text to search for in all properties (fulltext search) |
| Option | Description | Default |
|---|---|---|
--class <value> |
Resource class term, e.g. dctype:StillImage | |
--template <value> |
Resource template label | |
--site <value> |
Site slug or title | |
-p, --property [filter...] |
Exact property value as term=value, e.g. dcterms:creator=Leonardo (repeatable) | |
--public |
Only public resources | |
--private |
Only private resources | |
--query <value> |
Extra Omeka API query string, e.g. "sort_by=title&sort_order=desc" | |
--limit <value> |
Maximum number of results (default: 50) | |
--page <value> |
Page of results to show (with --limit) | |
-j, --json |
Output json | |
-c, --csv |
Output csv |
item-set:export¶
Export item sets as portable JSON-LD
| Argument | Description | Default |
|---|---|---|
[ids...] |
IDs of the item sets to export (default: all that match the filters) |
| Option | Description | Default |
|---|---|---|
--class <value> |
Resource class term, e.g. dctype:StillImage | |
--template <value> |
Resource template label | |
--site <value> |
Site slug or title | |
-p, --property [filter...] |
Exact property value as term=value, e.g. dcterms:creator=Leonardo (repeatable) | |
--public |
Only public resources | |
--private |
Only private resources | |
--query <value> |
Extra Omeka API query string, e.g. "sort_by=title&sort_order=desc" | |
-o, --output <value> |
File to write one exported resource to (default: standard output) | |
--output-dir <value> |
Directory to write one file per resource to | |
--reference-by <value> |
Property that identifies records in references and in the o-ref:id of each resource (default: dcterms:title) |
item-set:import¶
Import one item set from a JSON-LD file or URL
| Argument | Description | Default |
|---|---|---|
[source] |
JSON-LD file or URL holding one item set |
| Option | Description | Default |
|---|---|---|
--config <value> |
JSON file or URL describing the import: {"source", "title"} or {"title"} | |
--identify-by <value> |
Property whose value identifies an existing item set (default: the file's o-ref:id, else the title) | |
--dry-run |
Report what would be done, without doing it | |
-j, --json |
Output json |
media:add¶
Add a media to an item
| Argument | Description | Default |
|---|---|---|
<item> |
ID of the item |
| Option | Description | Default |
|---|---|---|
--data <value> |
The media as a JSON object: | |
--json-file <value> |
JSON file or URL holding the media object (see --data) | |
--ingester <value> |
Media ingester, e.g. upload, url, html, iiif, youtube (see media:ingesters) | |
--source <value> |
What to ingest: a local path or URL (upload), a URL (url, iiif, oembed, youtube) or HTML (html) | |
--title <value> |
Title of the media | |
--alt-text <value> |
Alternative text of the media | |
-j, --json |
Output json |
media:ingesters¶
List the media ingesters (the ways media can be added)
| Option | Description | Default |
|---|---|---|
-j, --json |
Output json | |
-c, --csv |
Output csv |