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.
Related
Folks, I was wondering what is the best way to model document and/or map functions that allows me "Not Equals" queries.
For example, my documents are:
1. { name : 'George' }
2. { name : 'Carlin' }
I want to trigger a query that returns every documents where name not equals 'John'.
Note: I don't have all possible names before hand. So the parameters in query can be any random text like 'John' in my example.
In short: there is no easy solution.
You have four options:
sending a multi range query
filter the view response with a server-side list function
using a CouchDB plugin
use the mango query language
sending a multi range query
You can request the view with two ranges defined by startkey and endkey. You have to choose the range so, that the key John is not requested.
Unfortunately you have to find the commit request that somewhere exists and compile your CouchDB with it. Its not included in the official source.
filter the view response with a server-side list function
Its not recommended but you can use a list function and ignore the row with the key John in your response. Its like you will do it with a JavaScript array.
using a CouchDB plugin
Create an additional index with e.g. couchdb-lucene. The lucene server has such query capabilities.
use the "mango" query language
Its included in the CouchDB 2.0 developer preview. Not ready for production but will be definitely included in the stable release.
I have a simple SDL Tridion 2011 SP1 Broker Query to retrieve a list of Component URIs. All of my Components are embedded on Pages, and not using Dynamic Component Templates. The following code returns 50 results (which is to be expected). One of which is the URI tcm:123-456-16.
List<Criteria> criteria = new List<Criteria>();
criteria.Add(new ItemTypeCriteria(16));
criteria.Add(new PublicationCriteria(337));
Query query = new Query(CriteriaFactory.And(criteria.ToArray<Criteria>()));
String[] results = query.ExecuteQuery();
The Component tcm:123-456-16 is based on a Schema with the name “News Portal”. I would like to add additional criteria to my query so that I only get items based on that Schema, so I tried the following code:
List<Criteria> criteria = new List<Criteria>();
criteria.Add(new ItemTypeCriteria(16));
criteria.Add(new PublicationCriteria(337));
criteria.Add(new SchemaTitleCriteria("News Portal"));
Query query = new Query(CriteriaFactory.And(criteria.ToArray<Criteria>()));
String[] results = query.ExecuteQuery();
This returns no results at all. I have double checked my Schema name. Is this response expected? Does the SchemaTitleCriteria require the Components to be published as Dynamic Component Presentations. Any advice would be greatly appreciated.
Yes and No on DCPs. You don't need to have all your components published as Dynamic Component Presentations (DCPs). We noticed the same and observed that if you don't publish at least one DCP based on the schema, the schema title does not get published into Schemas table of the Tridion Broker DB (not sure it is by design). Once you publish one DCP based on the schema, the schema title is stored and subsequent queries work, but until you publish that first one you will not get any.
However in practical scenario, you do broker queries to get the dcps so you should not see this behavior except a mistake or someone missed it.
Why would the component be present in the first result set, but not in the second?
I suspect this is unintended behaviour and worth raising with SDL.
To fix it you'll need to use ItemSchemaCriteria instead of SchemaTitleCriteria and obtain the components based on the schema ID, rather than the schema title.
To use the SchemaTitleCriteria I should imagine you need to have at least published one component based on the news portal schema alonside a dynamic component template so that the content delivery database contains the schema title information.
I want to join two tables in one of my linq query. I have written one code but it gives me an error like below
The method 'Join' is not supported.
I have tried this code:
var query = (from ls in this.testEntities.abc
join itm in this.testEntities.edf on ls.ID equals itm.ID
where itm.val == param
select new
{
ls.Name,
ls.Contact
}).ToList();
Am I missing something?
If anyone have any idea about it than please help me...
WCF Data Services is able to directly expand related objects based upon the Entity Data Model. (Don't worry about it if you don't know a lot about an EDM; it's not particularly important to the answer.) Since WCF Data Services is already aware, for instance, that a Product has a Category, I can fire up LinqPad, give it this URL, and issue a query like the following:
Products.Expand("Category").Take(2)
The result is two products, each with a property of type Category.
I'm not really sure what that translates to in the other LINQ syntax, sorry.
HTH,
Mark
I want to fetch data from two table buut i m realy confused.
just i want recent two users in my site but problem is there that two users releted information stored in other table .
I also used join query to fetch that data but proper result not get .
Are you getting the correct results when you run your query in SQL Server Management Studio (SSMS)? Make sure you can isolate where your problem is.
If the query returns the correct results when you run it in SSMS, then post up your code and we can help you find the problem.
If the query isn't returning your desired results post the table structure and the query and we can help you with that.
i am having my biztalk solution, uptill now i am able to do following thing
1) taken sql adapter as my source schmea i wanted node wise xml so i did xml auto,elements in my SP to its generate schmea nodewise
2) i am able to loop through all the nodes and checking condition in loop wioth decide shape now decide shape is executing perfactly,but now the issue comes i want to insert my current xml into table,from all the xml nodes i am getting single node's xml like following
<userDetails xmlns="http://SqlRowLooping"><userID>1</userID><fName>niladri</fName><lName>Roy</lName><department>it</department></userDetails>
now i have updateGram as well but i think it will accept data attibutewise,right now it is firing error saying cant find procedure userID,
help how to insert this in table,
how updategram will work..
thxs
Change the XML node to conform to updategram syntax, see MSDN