Extensis Logo SUPPORT | FORUMS | KNOWLEDGE BASE

Is metadata import via API supported in Portfolio 1.5


#1

Hello!

Can you tell me if it’s possible to load/import metadata into the elasticsearch db in Portfolio 1.5 via the java api using a java app running on an external host? A brief/basic example would be greatly appreciated!

The use case is that a user drops image files and a tab-delimited text file (or csv or whatever is supported) containing meta for those image that is then loaded into the appropriate fields in es after the files are move to the location they will be cataloged from (most likely a watch folder). Probably keying off of filename and destination path.

Thanks,
Charles


#2

Hi Charles,

Yes, that can be done with our API.

If you tell me a little about your tech stack, we can provide some sample code.

• Would you like to use the REST or SOAP API?
• What is the language you’ll be doing the work in?

Thanks in advance,
-Loren


#3

Hey Loren,

Sure thing.

We would like to use REST and we’re working in Java. The developer we have working on this is having issues accessing the data in es. She is writing/testing her code on a RHEL 7 VM, which is obviously a separate host from the Windows VM we’re testing Portfolio 1.(6 now) on. Once the java app is functional it will more than likely be deployed on one of our Linux app servers.

On a related note, is there a tool that is preinstalled with Portfolio that would allow us to see the data structure? Like Marvel, etc.? Any pointers would be very much appreciated.

Thanks!
Charles


#4

Hi Charles,

We don’t directly expose data in ElasticSearch.

Your developer needs to use the REST API endpoints /asset and /updateFieldValues to get and update metadata for individual assets or collections of assets.

The structure of the metadata is relatively flat, and per asset.

I will post a simple example of those two endpoints soon, but in the meantime, please point your developer to the REST docs here:
viewtopic.php?f=31&t=213

She can actually interact with her Portfolio server using those docs, it’s pretty cool.

Thanks!
-Loren


#5

Thanks Loren! We’ll check it out.


#6

Here are a couple very simple examples to get you started.

Again, I strongly encourage your developer to download our Swagger docs and use that system to interact with the API, it’s fun and easy!

  1. To get all fields for an asset:

Send a GET to

with body

{
	"fields" : ["*"],
	    "query" : {
        	"term" : {
	            "operator" : "assetsById",
        	    "values" : ["1"],
	    }
	 }
}

This will return all the metadata for a specific asset. This should let you explore the format and structure of the metadata.

  1. To update the metadata for a single asset (in this case adding a couple keywords):

Send a POST to

with body

{
    "embed" : false,
    "query" : {
        "term" : {
            "operator" : "assetsById",
            "values" : ["1"],
        }
    },
    "changes" : [
        {
		"action" : "add", 
	        "field":"Keywords",
	        "newValues":["foo", "bar"]
        }
    ]
}

#7

Thanks Loren!


#8

Hi Loren,

Is there something special we have to do to update custom field values? When we run the query to get field values, none of the custom fields are listed. Does the query ignore fields with null values?

localhost:8090/api/v1/catalog/96 … 27B09FAD83
{
“fields” : ["*"],
“term” : {
“operator”:“equalValue”,
“field”:“Path”,
“values”:["::stlpanzpoc01:cloudfs:stlpanzpoc01:nfs:deep:web:products:s:t:uploadTest.txt"]
}
}

Trying to update the custom fields also does nothing.

localhost:8090/api/v1/catalog/96 … 27B09FAD83
{
“embed”: false,
“query”: {
“term”: {
“operator”: “equalValue”,
“field”: “Path”,
“values”: [
"::stlpanzpoc01:cloudfs:stlpanzpoc01:nfs:deep:web:products:s:t:uploadTest 2.txt"
]
}
},
“fieldValuesChanges”: [
{
“action”: “add”,
“field”: “Brand”,
“newValues”: [
“Sigma”
]
},
{
“action”: “add”,
“field”: “ProductNumber”,
“newValues”: [
“z330019”
]
},
{
“action”: “add”,
“field”: “ProductName”,
“newValues”: [
“BRAND”
]
},
{
“action”: “add”,
“field”: “ProductKeywords”,
“newValues”: [
“wide-mouth bottles, LDPE”
]
},
{
“action”: “add”,
“field”: “Description”,
“newValues”: [
“a cute, plain, bottle”
]
},
{
“action”: “add”,
“field”: “Contributor”,
“newValues”: [
“cfredman”
]
},
{
“action”: “add”,
“field”: “Language”,
“newValues”: [
“us: en-us:English”
]
},
{
“action”: “add”,
“field”: “ObjectType”,
“newValues”: [
“photo”
]
}
]
}

Thanks!
Charles


#9

hi I’ve been working with Charles on this, and this is the response we get when using updateFieldValues:

{ "faultCode": "InvalidParameters", "message": "changes cannot be null" }

The body shown in the last post is what we are sending, howver, we also get this response when posting just a single field update as in the example given in the swagger tool.

This has us stumped. What are the changes being refered to? Is it the array of values under fieldValuesChanges?


#10

Well, we figured it out !! :smiley: Turns out that the changes list needs to just be called “changes”. Our working message body is below.
Also, we changed the action to “replaceAllValues”, since some fields are multivalue, and some are single value. This runs as part of an initial load process, so we don’t need to worry about existing values.

{ "embed": false, "query": { "term": { "operator": "equalValue", "field": "Path", "values": [ "::stlpanzpoc01:cloudfs:stlpanzpoc01:nfs:deep:web:products:s:t:uploadTest 2.txt" ] } }, "changes": [ { "action": "replaceAllValues", "field": "File Description", "newValues": [ "a cute, plain, bottle" ] }, { "action": "replaceAllValues", "field": "Brand", "newValues": [ "Sigma" ] }, { "action": "replaceAllValues", "field": "ProductNumber", "newValues": [ "z330019" ] }, { "action": "replaceAllValues", "field": "ProductName", "newValues": [ "BRAND" ] }, { "action": "replaceAllValues", "field": "ProductKeywords", "newValues": [ "wide-mouth bottles, LDPE" ] }, { "action": "replaceAllValues", "field": "Contributor", "newValues": [ "cfredman" ] }, { "action": "replaceAllValues", "field": "Language", "newValues": [ "us: en-us:English" ] }, { "action": "replaceAllValues", "field": "ObjectType", "newValues": [ "photo" ] } ] }


#11

Glad to hear you guys figured it out, thanks for the update!

As for the earlier issue of getting all field values when passing in a wildcard asterisk into the fields list, we are looking to see what is going on there. In the meantime, a workaround would be to provide an explicit list of field names to the query result options object instead.

Please let us know if that does not work for you. We will follow up with you when we determine the status of the wildcard feature.

Thanks,
-Loren


#12

Loren,
Actually once the update took, we then were able to see the custom fields on the query as well.
Also, if fields are updated manually in the UI, then the query will return them.
So, basically, it seems that for a new record, the asset query will not return custom fields until there are values initialized in those fields for that item.

John