I'm developing a shopping web site application. I need to get the most popular item in the shop. I'm using JPQL. In other words I need to get the most repeated item code from table. I tried with this-
select o.item from OrderDetail o GROUP BY o.item.id ORDER BY COUNT(*) DESC LIMIT 1
But I got the following error.
unexpected token: LIMIT
How to fix this error?
Thanks in Advance!
You can use the setMaxResults() on the query-Object created by the entity manager to limit the number of results
for example:
entityManager.createQuery(QUERY).setMaxResults(1);
Related
I need to get all the items of a SharePoint list and send as JSON
But the default is 100
If I set a larger number like 10000 it gives this error on the flow:
The attempted operation is prohibited because it exceeds the list view threshold.
So I am trying to get it in batches of 350 items.
But how can I use the Filter Query to start at a position x and return y items?
I tried
$skip eq 350
But this error occurs:
Column 'skip' does not exist
I think your question has 2 layers to it.
To increase the number of items returned by the Get Items Actions from Sharepoint you need click on the three dots on the left side of the action, and then go to Settings and you will see the image below, then set the size to 5000, that means your Get Items action will now return a maximum of 5000 items.
$top and $skip - I am not too confident what you are trying to do with this but perhaps share a bit more context, it sounds like you want to build a dynamic pagination ? Please explain this part unless the first point already achieve what you were aiming for
I need to be able to execute the following query or something similar:
SELECT count(1) AS userCount, f.gh
FROM f
WHERE f.location.coordinates[1] < <MAX_LAT>
AND f.location.coordinates[1] > <MIN_LAT>
AND f.location.coordinates[0] > <MIN_LNG>
AND f.location.coordinates[0] < <MAX_LNG>
GROUP BY f.gh
I have a collection that stores user's coordinates on a map. When zoomed in, I want to display individual users locations, but when zoomed out, I want to display the amount of users in a location grouped by their 5-character geohash. This query is exactly what I want, however you cannot run group-by queries over rest api, as mentioned in the docs.
Queries that cannot be served by gateway
It doesn't offer any alternatives to this, and I'm still pretty new to Cosmos. How can I successfully run this query?
The issue ended up being that I was trying to call "group by" through azure function bindings, and not the actual .NET SDK Nuget package. Thanks for the help.
I'm not sure I have a syntax error here in my CAML Query or I am misunderstanding how the API works but I have a very large document library in which I am trying to identify items that have had no compliance / retention label set.
My query is trying to return any item in the library that does not have the compliance retention label set to "Test". This is the query but regardless of rowlimit, the console app returns the threshold error... "The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator."
<View Scope='RecursiveAll'><RowLimit>20</RowLimit><Query><Where><Neq><FieldRef Name='_ComplianceTag'/><Value Type='String'>Test</Value></Neq></Where></Query></View>
I have been trying the most basic query and I can confirm this works...
<View Scope='RecursiveAll'><RowLimit>20</RowLimit></View>
But as soon as I add element to the CAML, I get the error. It seems once the query is added it ignores my row limit. The plan is to bring the items back in small batches and apply the label. I've already built a console app which uses the SetComplianceTag to library method. This applies Tags to everything in the library but unfortunately my library is so large we found it missed a few.
Any insights would be much appreciated.
Having read further I now understand the query is executed on the entire list so limits apply regarless of the rowLimit in your CAML. I have now copied and adapted what Piyush K Singh has done in the tutorial linked below. There is a ListItemCollectionPosition object which can handle breaking your API request into batches the size specified in your row limit. I then loop through each batch looking for the items that match my specified conditions...
https://piyushksingh.com/2016/12/04/query-listitems-in-batches-sharepoint-online/
Thanks Piyush!
Currently we are getting all lists in all sub sites using below REST query.
'/_api/Web/Webs?$expand=Lists&select=Title,id,ParentWebUrl'
now we would like to get the all content types that are used in those lists as well. Tried expanding ContentTypes, but could not get it to work.
Can anyone help to get content types belong to those lists? Even if filtering by content type in the REST query it self is fine.
or is there any way to do this in search results of lists?
After searching everywhere and getting no answers here, I've come to the conclusion there is no possibility of doing this way. So, I've used SharePoint Search services to get my results.
querytext = 'path:"your site collection path" AND (ContentClass:"STS_List_GenericList" OR ContentClass:"STS_List_DocumentLibrary")';
Later I decided to add listIDs to the query as I was getting ListIDs from previous Item search.
querytext = '(ListID:"Your list1 ID" OR ListID:"Your list2 ID" OR ListID:"Your listn ID")" AND (ContentClass:"STS_List_GenericList" OR ContentClass:"STS_List_DocumentLibrary")';
The issue was now if the list IDs exceed more than 75, the querytext max character exceeds and no results was received.
After searching a way to increase the maximum limit and finding out there is no way to do it, I divided the list IDs into a set 75 IDs and send separate requests for each set, then combined all together.
You can read it how it was done here Batch Search requests
This is the REST call for a SharePoint Online tenant (you did not specify version). If you iterate your through your list and call this for each list, you can summarize what content types are on your site.
https://YOURTENNANT.sharepoint.com/sites/YOURSITE/_api/lists/getbytitle('YOURLISTNAME')/contenttypes
I created two lists in my SharePoint 2010 site. one has 10 items other has 10000 items.
On the small list I can say
http://mysharepoint.com/sites/testsite/_vti_bin/listdata.svc/SmallList?$top=1&$skip=1
no problem it works perfect.
when I say
http://mysharepoint.com/sites/testsite/_vti_bin/listdata.svc/LargeList?$top=1&$skip=1
it throws an error "An error occurred while processing this request"
The internet is full of confustion because most blogs/articles etc talk about "SP2013" where I guess there is a __next in the body of XML which you get from SP.
However I am using SP2010 and this is a PURE client side solution with NO server side object model at all.
Can anyone tell me how to paginate through large lists "specifically" on SP2010.
Please post some working URLs with rest commands.... which you have tested against a large list (please let me know if you need me to provide code which will create a large list of 10K items for you).
You could do it using JavaScript and the WebServices. With the JavaScript API library I created, called SharepointPlus, you'll have to do that (with version 3.0.7):
$SP().list("Name of your list").get({fields:"ID,Title",rowlimit:5000,paging:true},function(data) {
console.log(data.length)
})
You'll have all the items into the 'data' array. You can go thru the array and stop when you reach X elements in a JavaScript loop for example. Like that you should not have an error message due to the large size of your list.
$skip query option is not supported, but $top is.
Workaround, use a mix of $orderby on ID, $filter on ID and $top x items, and loop.
Your query becomes
http://mysharepoint.com/sites/testsite/_vti_bin/listdata.svc/LargeList()?$orderby=Id&$filter=Id gt {lastId}&$top=100
{lastId}=0 on the first run.
Loop the items found, keep track of the "Last Id" and pass it to the next query.
http://mysharepoint.com/sites/testsite/_vti_bin/listdata.svc/LargeList()?$orderby=Id&$filter=Id gt 0&$top=100
http://mysharepoint.com/sites/testsite/_vti_bin/listdata.svc/LargeList()?$orderby=Id&$filter=Id gt 123&$top=100
http://mysharepoint.com/sites/testsite/_vti_bin/listdata.svc/LargeList()?$orderby=Id&$filter=Id gt 345&$top=100
repeat.
Note 1: ID is a column that is always indexed, other
Note 2: This pattern also works with the REST API (LINQ query)