how to find path of a node under /etc/tags in AEM? - aem

I want to search a tag under /etc/tags in AEM programmatically.
for ex:
folder structure is like
/etc/tags/
uder tags there are multiple tags
1.20101/ate2
2.73883
3.44qqiw
4.222
if i want to search ate2 i should get /etc/tags/20101/ate2.

You can use QueryBuilder API to query it.
Sample Query would be
type=cq:Tag
path=/etc/tags
nodename=ate2
Sample SQL2 Query for the same would be
select * from [cq:Tag] as s where ISDESCENDANTNODE('/etc/tags') AND NAME(s)='ate2'

One solution is write the query as suggested by rakhi, other is to utilize TagManager API that provides you lot of methods to search tags and once you get Tag instance you could get path from it. Javadocs for TagManager can be found here and for Tag here
For reference you could look at the code here. One thing to keep in mind in case you end up using this approach you will need to work by creating a system user to get ResourceResolver instead of calling resolverFactory.getAdministrativeResourceResolver(null), refer to article here

Related

How to generate and resolve custom URLs with TYPO3 9.5

Am using $GLOBALS['TSFE']->cObj->typoLink to generate a link and I've an additional parameter like this: ext__pluginname[d64]=31511 and would like to return something like a/b/c. I would then want TYPO3 to give me back the link so I can resolve it when clicked. I've already tried PersistedAliasMapper but won't allow to return anything with a slash in it. I've even tried a custom aspect mapper. I get the error:
Parameter "tx_ext__pluginname__d64" for route "enhancer_tx_ext__pluginname000000003e62d21a000000000514759a" must match "[^/]++" ("a/c" given) to generate a corresponding URL.
Am able to generate and resolve the slugs(urls). I can store them in db and retrieve them for that matter. No problem.
Am generating them from root page (uid 1).
How can i get this to work?
I assume you already have created the desired path in a database table or view already, making use of the slug feature in the TYPO3 backend or creating it yourself.
You could then use the PersistedAliasMapper in your site config (config/sites/default/config.yaml).
If you need multiple values in a single path divided by slashes (not a combined slug field), take a look at the route configuration for the news extension. You just have to use database mappers instead of static ones, but keep in mind this may impact the performance of the routing!
As you did not provide much detail about your use case, I don't really understand why you need such a path structure with slashes.

Search string formatting in Elouqa API

I'm using the Elouqa Rest API in an integration with another product and I want to implement a file browser. As part of this I want to get a list of the folders inside another folder. Theapi documents here say that a search string can be appended but don't give any clues as to the format of the search string. I've tried various things but so far I'm just getting empty results. An example is here:
/API/rest/1.0/assets/email/folders?search=folderId+%3D+250
I've tried with and without +'s and with and without url encoding the = sign, also various combinations of quote marks but so far nothing.
I believe what you want is a slightly different endpoint e.g.:
/API/rest/1.0/assets/email/folder/250/contents
Which would provide a list of folders contained with folder 250
If you wanted to search for a given folder name then you would use
/API/rest/1.0/assets/email/folders?search=foldername
Hope that helps!

Search code in the repositories whose name contains a keyword

In github search, the following string allows me to search JavaScript code that contain Acode in all the repositories of the user NameOfUser:
user:NameOfUser language:JavaScript ACode
Now, I would like to add another condition: i am only interested in the code containing ACode in the repositories whose name contains repokey.
Does anyone know how to write the request?
The search API already does this. You can just use the search that you've posted above to search for repositories containing the text you've specified.
For example...
user:mrdoob language:JavaScript Three Extension
returns this...
https://github.com/search?utf8=%E2%9C%93&q=user%3Amrdoob+language%3AJavaScript+Three+Extension&type=Repositories&ref=searchresults
As above answer I also tried with type=Code and added a "WebGLBufferRenderer" keyword, See if it helps:
https://github.com/search?utf8=%E2%9C%93&q=user%3Amrdoob+language%3AThree+Extension+WebGLBufferRenderer&type=Code&ref=searchresults

Custom Search Results in REST MarkLogic

So new to MarkLogic am stuck and not finding the documentation of use. I know what i need to do, just do not know how to do it.
I have a keyvalue? search on my REST server which returns ML's standard search results and XML snippet. I want to create my own custom search result which will output a title element for my XML files.
I am aware that i need to create an XSLT transformation document and upload that to the server but do not know how to target ML's search function or how to write this out.
I have basic knowledge of XSLT, if i just created something that targets each files title using xPath will this work, or does ML require use of their custom functions?
I know its a bit broad, but hopefully someone can point steer me.
Sounds like you are talking about the GET /v1/keyvalue endpoint of MarkLogic REST API. Unfortunately that does not allow you to choose a transform. You can probably use GET /v1/search with a transform param instead though, using a structured query for an element value query. The docs contain a good syntax reference on that.
Docs on creating and managing transforms can be found here:
http://docs.marklogic.com/guide/rest-dev/transforms#chapter
HTH!
You can use extract-metadata in your search options with search:search or the /v1/search/ REST API endpoint to include the title element in a metadata element or JSON property in your results:
import module namespace search = "http://marklogic.com/appservices/search"
at "/MarkLogic/appservices/search/search.xqy";
search:search(
"my query string",
<options xmlns="http://marklogic.com/appservices/search">
<extract-metadata>
<qname elem-ns="" elem-name="title"/>
</extract-metadata>
</options>)
If you need more flexibility, you specify a custom snippet implementation or a results decorator function in your search options.
Is this key-value or full text? For key-value you could use XPath. Any XPath that starts with / or // or fn:collection() or fn:doc() will search the entire database. You can search specific document(s) or collection(s) too.
For full text you'd probably want to use https://docs.marklogic.com/search:search - or possibly https://docs.marklogic.com/cts:search for really low-level control.
There's some example code using search:search from XSL at https://github.com/marklogic/RunDMC which might help. It doesn't use the REST API: it's a traditional form-submit web page. But the view/search.xsl code might give you some idea how to call the search API from XSLT.
That RunDMC code might also help you if you need to call XSL from XQuery: take a look at controller/transform.xqy.

Finding a download URL from the NuGet OData feed

What's the trick for deriving a download URL given an entry in the Packages table in the OData data set?
< content type="application/zip" src="SOME-URL" />
Under the <entry/> node, look for a <content/> node which contains 2 attributes type and src. The src attribute contains the download url. You could use LINQ to XML to get it. Seems easy, right? Oh, and remember to append an XNamespace to the XName when using LINQ to XML to query the nodes.