AnsweredAssumed Answered

Example of custom metadata query?

Question asked by Doug Toppin on Sep 4, 2015

I'm trying to get a query using custom metadata working via the ReST api (using curl) and have not been able to get it to work correctly.


If I had the following custom-metadata (copied from the namespace console):




<meta-data name="abc.def.ghi.jkl.nmo" value="my-value"/>

<meta-data name="abc.def.ghi.jkl.pqr"  value="another-value"/>




What is the correct xml query to retrieve a list of only the files containing the my-value entry for the key abc.def.ghi.jkl.nmo?


The following returns every file that contains my-value but without regard to the name.

<queryRequest><object><query>customMetadataContent: "my-value"</query></object></queryRequest>


What I want is something that will return only the files that have this specific metadata field and value: abc.def.ghi.jkl.nmo=my-value


Can someone explain what I am doing wrong?


In looking at the "HCP Metadata query API Reference" document it looks like the query should be this (which does not return any result set) so I am misunderstanding something:


<queryRequest><object><query>customMetadataContent: ""</query></object></queryRequest>

I have confirmed that custom indexing of metadata and full custom indexing are both enabled.

I would appreciate any tidbits on how to do this.

A little followup on this.

The following query will return the file that I expect but it is not associating the my-value with abc.def.ghi.jkl.nmo but instead is simply saying that both appear in the metadata which is

not exactly what I want.

<queryRequest><object><query>customMetadataContent: (+"abc.def.ghi.jkl.nmo" +"my- value")</query></object></queryRequest>

In looking at the "about search and indexing" section of "Managing a Tenant and Its Namespaces" I am starting to think that I need to create content properties to be able to do key/value type queries.

Is that true?

To add a little more to this I also noticed that I am getting back results that include entries with this in their path: "/rest/.lost%2bfound/replication/". That is from replication collisions and I am wondering how to exclude those from the search results. I am trying variations on this "-objectPath:("/rest/.lost%2bfound/*")" but that has no effect.

Another follow up on this, to exclude replication collision files include this in your query: +(replicationCollision:false)