By using Apache Cmis query, if I understand correctly, you can get either
a List of Cmis Folders (SELECT * FROM cmis:folder WHERE...)
a List of Cmis Documents (SELECT * FROM cmis:document WHERE...)
But what I need, is a List of cmisObjects. I need this abstraction, because I want to get all the children (Folder or Document) of the selected Parent Folder.
Using 2 queries (1 for each type) is not an option, as I also have to use paging (using OperationContext.setMaxItemsPerPage) over the query results
EDIT : Just to make sure I made myself clear, I need to
Use the query Function, as I need to filter my results by using a specific custom aspect
Use Pagination, because even after filtering, the results (Folder Children) can be up to hundreds
This one has hit me years ago (I gave up on CMIS at that time). As of CMIS 1.1, there is this optional cmis:item. Have a look at http://docs.oasis-open.org/cmis/CMIS/v1.1/CMIS-v1.1.html#x1-220002 . You may be lucky and find that working with Alfresco. It might be required to use the v.1.1 implementation of the spec.
If that does not work, I guess your only option is to abondon CMIS for this query and either use another search service or roll your own.
Good luck ! ;)
If you know your parent, why don't you just call getChildren on the parent? Do you really have to use a query?
http://chemistry.apache.org/java/0.9.0/maven/apidocs/org/apache/chemistry/opencmis/client/api/Folder.html#getChildren()
Related
Our MarkLogic based web-application mostly uses cts.jsonPropertyValueQuery to access needed information.
We want to provide the possibility of wildcard searches against specific JSON properties.
What is the best way to do it?
Turning on one of the wildcard indexes for the whole database is not an option.
I figured out that adding a "wildcarded" parameter to the query itself may solve the problem:
cts.search(cts.jsonPropertyValueQuery("inventor", "R?th", ["wildcarded", "whitespace-sensitive"]));
But it may work slow due to the absence of indexes. Is there any way to create wildcard indexes only for that specific JSON property?
You could create a Path Field with an XPath to the inventor JSON field (and even for //inventor) and configure the field to have wildcard indexes, and then use a field query: cts.fieldValueQuery or cts.fieldWordQuery.
I am running a following AEM Query SQL2 on CRXDE and it is successfully returning me nodes as per following given screenshot.
But I need data like column wise (jcr properties) like SQL table. Can anyone help me if it is possible.
You can't do this with CRXDE. It shows only the path of the most outer node, even if the query has multiple columns. This is especially limiting, if your query uses joins.
In your case I would recommend the Query Builder. It has a totally different syntax, but the JSON or XML result contains all data you need.
I don't know other tools. As AEM developer I usually write a quick & dirty servlet, and let it run on my local instance (with production content)
Query Builder Debugger
http://localhost:4502/libs/cq/search/content/querydebug.html
Example Query
path=/content/we-retail/language-masters/en/experience
property=sling:resourceType
property.value=weretail/components/content/image
p.hits=full
p.nodedepth=2
Resulting JSON Query
http://localhost:4502/bin/querybuilder.json?p.hits=full&p.nodedepth=2&path=%2fcontent%2fwe-retail%2flanguage-masters%2fen%2fexperience&property=sling%3aresourceType&property.value=weretail%2fcomponents%2fcontent%2fimage
http://localhost:4502/bin/querybuilder.json?p.hits=full&p.nodedepth=2&path=%2fcontent%2fwe-retail%2flanguage-masters%2fen%2fexperience&property=sling%3aresourceType&property.value=weretail%2fcomponents%2fcontent%2fimage
Documentation
https://docs.adobe.com/content/help/en/experience-manager-64/developing/platform/query-builder/querybuilder-api.html
In your case especially see: Refining What Is Returned
You will find much more with Google, as the Query Builder is pretty old in AEM/CQ.
I'd like to know how to get all nodes of a given type ts:folderSet which has no parent association of type ts:FolderSubSet informed.
Currently:
So, I mean, I need all nodes of type ts:folderSet where tsfss:folderSubSet-folder is null or not informed.
Currently, I'm using admin tool in order to build this query, but I'll need to use it into a java code.
So I mean, I can use FTS or lucene...
Any ideas?
If your parent type is different you can do:
+TYPE:"ts:folderSet"
The problem is that the PARENT keyword in search uses the primary parent. Your ts:folderSubSet object is a secondary parent to your ts:folderSet object. I don't think you will be able to write a single query that can find instances of ts:folderSet that do not have an instance of ts:folderSubSet as a secondary parent.
You can write a query that returns ts:folderSet objects and then you can iterate over each one of the results checking its list of parents for the secondary object. Not ideal, but it is probably the best you can do.
You can search for a type of nodes using the following Lucene query
TYPE:"cm:folder"
I Want to retrieve All document content from alfresco repository. So can anyone help me that how can i traverse the repository using CMIS. And while traversing i also want to separate the documents based on its type.
At this moment i am able to get any one document by specifying the path. but now my requirement is to traverse whole repository and get all the documents.
So can any one help me with this.
Also suggest me that "Traversal of all folders and later separate by specific type" will be the good approach OR "Search specific type of document using CMIS query" will be the good approach.
Thanks in Advance.
Yagami's answer is a good start, but there are a few things to add.
First, do not do "select *" unless you actually need every single property the repository has. That is a potential performance problem. Only ask for what you need.
Second, one of your comments talks about segmenting results by type. In CMIS, a type is kind of like a SQL table. So in your case, you would do three different queries using each of your three custom types as a different type in the from clause:
select * from test:mainContract;
select * from test:subContract;
select * from test:royaltyStatement;
Finally, unless you have just a handful of documents in your repository, you are almost certainly going to want to use a paged result set. Otherwise, you will only get back the maximum number of results the server is configured to return. That may not be large enough to get the entire set.
For an example showing paging the result set, see Apache CMIS: Paging query result
To perform an action like this (getting all the document content) you need to follow this steps
Step 1 : Create a saver Class
What i mean with sever class, it will hold two information (for me it's the most valuable informations) the two of them most be character varying
1 - The document ID
2 - The document Name
Step 2 : Get all the document
To get all the document we have to use a query
String query;
query = "SELECT * FROM cmis:document ";
You will get all the document that you have in your repository.
You can add some condition to make your research more easier like in this example :
query = "SELECT * FROM cmis:document WHERE IN_FOLDER('" + folderId + "')";
In this example you will get document of a particular folder.
ItemIterable<QueryResult> resultList = session.query(query, false);
and finally
for (QueryResult qr : resultList) {
String idDocument = qr.getPropertyByQueryName("cmis:objectId").getFirstValue().toString();
String name = qr.getPropertyByQueryName("cmis:name").getFirstValue().toString();
Document doc = (Document) session.getObject(idDocument);// this is how you can get document with add that's mean no need of path
}
You can read more about query in CMIS query.
Step 3 : Save every time the information in the saver class
I think it's clear that you have to save every time you use the loop (in step 2) in an occurence of saver class.
I hope that helped you.
I have title search with Lucene .net and facing problem with LIKE clause search.
I have tried below terms but it is matching whole word.
query.Add(new TermQuery(new Term("title", word.ToLower())), BooleanClause.Occur.MUST);
Also tried
query.Add(new TermQuery(new Term("title", word.ToLower())), BooleanClause.Occur.SHOULD);
Any idea how to apply LIKE clause?
I would guess you are probably looking for either Prefix or Wildcard queries.
In general, I'd recommend getting some level of understanding of the instantiable subclasses of Query, listed here.