How to execute "group by" queries in Cosmos DB? - azure

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.

Related

NetSuite: How can I get a list of custom fields using suitesql or REST?

Using the REST suiteql query endpoint or the records endpoints, is there a way to query NetSuite to get a list of custom fields?
You can use SuiteQL to list customfields.
For example to list entity custom fields:
{
"q": "SELECT * FROM CustomField where fieldtype = 'ENTITY'"
}
Use Setup -> Records Catalog to see the records you can query. It includes custom records and custom lists. ex. If you have a custom list called customlist_year then the records browser will include it and you can do a query like: SELECT * FROM customlist_year with SuiteQL.
One caveat: SuiteQL is still in development so the fieldnames and results might change with a NetSuite release. Make sure things get tested with a Release Preview account so you are ready for any changes when they hit your production account.
Using RESTWEB Services you can fetch the schemas of the objects. Below is the screen shot which gives the sample rest web service request.
enter image description here
Any specific reason to use suiteqql? With a normal RESTlet you can load a dummy record and read all field names starting with "cust".

LogicApp that returns newly generated ID back to original source

Hello I am trying to create a LogicApp that first:
Extracts data from CosmosDB, using a query
Loops over the results
Pushes the results data into CRM
Sidenote: Once this data is pushed into CRM, CRM automatically generates an ID for each record. How can I then:
My biggest dilemma is figuring out how can I return the newly generated ID back to the original CosmosDB container in which it was pulled from?
I have started on this and these are my questions:
Does this first part look correct in what I am doing? I must use this SQL query for this:
a. I am simply telling the Logic App to extract data from a particular container inside CosmosDB
b. Then I would like to loop over the results I just obtained, and push this to CRM
c. My dilemma is:
Once data is pushed to CRM, CRM then automatically generates an ID for each record that is uploaded. How would I then return the updated ID to cosmos?
Should I create a variable that stores the IDS, then replace the old IDs with the new ones?
I am not sure how to construct/write this logic within LogicApps and have been researching examples of this.
Any help is greatly appreciated.
Thanks
If the call to your CRM system returns the ID you are talking about then I would just add one additional action in your loop in Azure Logic App to update the read record in Azure Cosmos DB. Given that you are doing a SELECT * from the container you should have the whole original document.
Add the 'Create or update document' action as a step with a reference to the THFeature container along with your Database ID and then provide the new values for the document. I pasted an example below.
BTW. Your select query looks strange - you should avoid slow cross partition queries if you can.

SharePoint view limitation

I have a document library in SharePoint online. I keep on dumping the records into it. As SharePoint have a 5000 record view limitation the moment it reaches that limit, still I will be able to upload documents but it doesn't show up any where.
Eventually I end up creating a new view and apply a filter and then the document starts showing up under the new view.
My question here is: Is there a way to automatically create a view when it reaches the 5000 limitation and put the newly uploaded documents to the new view.
Yes, you can do this via MS Flow/Workflow & server side apps/scripts of course but it's not a good approach to the issue IMO.
Have you indexed the columns? I just tested this now on a document library with 20k documents and I'm able to filter. There are limitations which you should look into (complex filtering), that's where compound indexes come in.
If you still have issues then I recommend you give the highlighted content web-part a try. You can create custom search queries & it looks similar to a document library if u set the settings correctly. The only meh thing about this approach is there is a delay for search to update, from 15 mins to 6 hours depending on how much data you have

IBM Maximo: Start Center and Multiple Tables

I am trying to help a colleague out. I created a query in IBM Maximo 7.6, it is in the work orders table but I added a sub query that pulls from the workflow table and filters for anything in Work Flow.
My question is: On the start center, is there anyway to modify the results set so that we can pull fields from work order and work flow? I have work number, status, and vehicle. Basically, is it possible to bring in what inbox the work order is in, on the results set, in graphical form. So, put together a bar graph based on the inbox?
Any direction would be great, thank you!
First, you need to make sure there is a Relationship on the WORKORDER object in Database Configuration that will find the workflow record you want to see info from for a given work order. Once you've done that, these instructions show you, step by step, how to create Report Object Structure (ROS) (an Object Structure "Consumed By" Reporting), how to grant access to the ROS, and then how to use the ROS in a Result Set portlet to access data in related objects.

Office365 REST API query calendar entries for only events outside of work hours

I'm trying to get a log of all entries in my Outlook calendar that occurred before 9AM and after 5PM. Is there a way I can query that via REST, or do I have to retrieve all entries locally and evaluate the data their data there?
I've checked
https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#RESTAPIResourcesEvent
and
https://msdn.microsoft.com/office/office365/APi/calendar-rest-operations#GetEventCollection
But while there is $search and $filter options, for the Start field is a full DateTime, not just time, so, on first glance, trying to figure these things out doesn't seem capable.
$filter does have and, or, lt and gt, among other operators, but it doesn't seem to have like a SQL, or mongo like operation that I could maybe query for a list of start times for any date, or better yet, a regex string operation.
It's looking like I'll have to just get all entries, and work from there, but I definitely thought I'd ask before doing that.
Have you looked at the calendarview endpoint? It gives all appointments within a window:
GET https://outlook.office365.com/api/{version}/me/calendarview?startDateTime={start_datetime}&endDateTime={end_datetime}
https://msdn.microsoft.com/office/office365/APi/calendar-rest-operations#Getevents

Resources