Query assets with tags via Nuxeo .net client

Hi all,

In my project I am using the Nuxeo .NET client for querying the assets and until I decided to introduce tags in my project everything worked perfeclty. However, the issue I am facing is querying the assets with more than one tag in the query.

For example, in the Nuxeo repository I have an image asset tagged with the tags: one, two… When I trigger the search via Postman using the following query:

SELECT * FROM Document WHERE dc:title='CorrectTitle' AND ecm:tag='one' AND ecm:tag='second' AND ecm:isTrashed=0 AND ecm:isVersion=0

I get the correct result.

However, when I do the same using the nuxeo .NET client like below the result is empty. When only one tag is included in the search query, the result is correct.

Documents docs = (Documents)_nuxeoClient.Operation("Document.Query")
                .SetParameter("query", "SELECT * FROM Document WHERE dc:title='CorrectTitle' AND ecm:tag='one' AND ecm:tag='second' AND ecm:isTrashed=0 AND ecm:isVersion=0")
                .AddHeader("X-NXDocumentProperties", "*")
                .Execute()
                .GetAwaiter()
                .GetResult();

Can somebody please tell me what is it that is preventing the .NET client from searching for more than one tag in the document?

0 votes

1 answers

807 views

ANSWER



Hello,

Your NXQL query should be SELECT * FROM Document WHERE dc:title='CorrectTitle' AND ecm:tag IN('one','second') AND ecm:isTrashed=0 AND ecm:isVersion=0" for document with one or second tag. If you need AND (meaning, your need the two tags on the document), it should be SELECT * FROM Document WHERE dc:title='CorrectTitle' AND ecm:tag/* = 'one' AND ecm:tag/* = 'second' AND ecm:isTrashed=0 AND ecm:isVersion=0"

This is described in https://doc.nuxeo.com/nxdoc/nxql/#special-nxql-properties

Regards

0 votes