My folder structure
Inbox
|- FolderA
| |-ChildA1
| |-ChildA2 ect.
|
|- FolderB
|-ChildB1
|-ChildB2 ect.
The problem
In the documentation is stated that the id-property for a mailFolder is unique. But several childs from FolderA does have the same id's as childs from FolderB.
a child of FolderA
Array
(
[id] => AAMkADc3NmMwNWE3<...>aXeP4l9AAAH2RGbAAA=
[displayName] => childAx
[parentFolderId] => AAMkADc3NmMwNWE3<...>aXeP4l9AAAETiFqAAA=
...
)
a child of FolderB
(
[id] => AAMkADc3NmMwNWE3<...>aXeP4l9AAAH2RGBAAA=
[displayName] => childBx
[parentFolderId] => AAMkADc3NmMwNWE3<...>aXeP4l9AAAETiFtAAA=
...
)
As shown multiple mailFolders does have the same id.
Steps I took
Using /users/{id | userPrincipalName}/mailFolders/Inbox/childFolders I get the id's for FolderA and FolderB. After that I get the childFolders for both folderA and folderB via /users/{id | userPrincipalName}/mailFolders/{id}/childFolders
When using /users/{id | userPrincipalName}/mailFolders/{id} I get the mailFolder data from one of the folders with the same id's. How can I point out to another? Using a combination of the parentId and id?
I am unable to reproduce your issue. I have however noted that the ids are similar to some extent but not the same value. There is at least one digit difference. See below I have four sub children and each have a unique id with largely the first parts being the same
Folder A
Folder B
If you see any duplicate folder ids to exact matches, you may need to create a support request.
Related
I'm implementing chat using Firestore. Here is the structure of Firestore:
|- Chats (collection)
|-- AutoID (document)
|--- user1ID (String)
|--- user2ID (String)
|--- thread (collection)
... and then thread has further fields.
In order to get chat between two users I'm fetching it like:
let db = Firestore.firestore().collection("Chats")
.whereField("user1ID", isEqualTo: Auth.auth().currentUser?.uid!)
.whereField("user2ID", isEqualTo: user2UID!)
It works fine if user 1 is the current user otherwise if I open chat from other account and current user is user 2 it doesn't fetch this document.
Upon searching I found that I can user arrayContains. So I made an array instead called users and in it I've added both these IDs. So now the structure is:
|- Chats (collection)
|-- AutoID (document)
|--- users (Array)
|---- 0: user1ID (String)
|---- 1: user2ID (String)
|--- thread (collection)
... and then thread has further fields.
But when I do:
let db2 = Firestore.firestore().collection("Chats")
.whereField("users", arrayContains: Auth.auth().currentUser?.uid!)
.whereField("users", arrayContains: user2UID!)
It's going to fetch the first document it found that has currentUser.uid (Haven't tested it, I'm saying this based on the documentation I've read).
So, how can I get this chat, if an array contains both id's?
Firstly, the document you outlined doesn't have any array type fields, so arrayContains isn't going to be helpful. arrayContains only matches items of a field that contains an array.
For your current document structure, a single query will not be able to get all the documents between both users, since Cloud Firestore doesn't offer any logical OR type queries. You are going to need two queries: one for getting all documents where user1 is the current user, and one for where user2 is the current user. Then you can merge the results of those two queries in the client code to build the entire list.
What I typically do is to name the document for the two users that are having the chat. That way you don't need to do a query to find the document, but can just directly access is based on the UIDs.
To ensure the order in which the UIDs are specified doesn't matter, I then add them in lexicographical order. For an example of this, see my answer here: Best way to manage Chat channels in Firebase
My problem is I put data into Neo4j from what was essentially a large spreadsheet essentially. Now I want to be able to get that data back out in a similar tabular format.
Lets say I have some notional spreadsheet of data that went in looked something like the following.
| Artist | Album | Song | Live | Filename | Genre | Year | Source | Label |
|--------|-------|------|------|----------|-------|------|--------|-------|
| .... | ..... | .... | .... | ........ | ..... | .... | ...... | ..... |
---------------------------------------------------------------------------
The spreadsheet was a listing of files with some metadata about each file. For analytic purposes it made more sense to not have the file be at the center of the graph but rather the Albums. So that every record in the table above would map to a handful of nodes and relationships. The data model for this might look something like this:
(Song)-[_IS_ON_]->(Album)
(Artist)-[_SINGS_]->(Song)
(Album)-[IS_IN_]->(Genre)
(Song)-[_IS_IN_]->(Genre)
(Album)-[_IS_]->(Live)
(Album)-[_FROM_]-(Year)
(Album)-[_IS_ON_]->(Source)
(Label)-[_PRODUCED_]->(Album)
I am able to query a single record from my spreadsheet above using a query similar to this.
MATCH (a:Album {name: "Hells Bells"})-[r]-(b)
OPTIONAL MATCH (s:Song)<-[_SINGS_]-(aa:Artist)
RETURN *
I have two questions here.
How do I make the above query return a table that looks similar to the original normalized table? If I did RETURN b.filename, b.genre ... I get a table that has a lot of null values. It would seem I need to do a DISTINCT on each of the fields. But I am still really new to Neo4j and am not positive I understand how to do this.
It would be great if there was a way to get all the fields in all the nodes without having to type them out in the query like this RETURN b.filename, b.genre .... I think I figured this out once but I stupidly didn't save it.
I hope this was clear enough. I can't share my graph model or data so I had to make this up on the fly.
TIA
Try the following (but, since you did not state how to get the filename, that value might be missing):
MATCH
(artist:Artist)-[:_SINGS_]->(song:Song)-[:_IS_ON_]->(album:Album {name: "Hells Bells"})-[:_FROM_]-(year:Year),
(album)-[:_IS_IN_]->(genre:Genre),
(album)-[:_IS_]->(live:Live),
(album)-[:_IS_ON_]->(source:Source),
(label:Label)-[:_PRODUCED_]->(album)
RETURN *
In a RETURN clause, if you specified a node/relationship (without a property name), that would generate a map of all its properties. The above query, for example, would return a map for each matched node.
If you actually want to have a single merged map, you can use the APOC function apoc.map.mergeList. For example:
MATCH
(artist:Artist)-[:_SINGS_]->(song:Song)-[:_IS_ON_]->(album:Album {name: "Hells Bells"})-[:_FROM_]-(year:Year),
(album)-[:_IS_IN_]->(genre:Genre),
(album)-[:_IS_]->(live:Live),
(album)-[:_IS_ON_]->(source:Source),
(label:Label)-[:_PRODUCED_]->(album)
RETURN apoc.map.mergeList([artist,song,year,genre,live,source,label,album]) AS result
I store data in XML files in Data Lake Store within each folder, like one folder constitutes one source system.
On end of every day, i would like to run some kid of log analytics to find out how many New XML files are stored in Data Lake Store under every folder?. I have enabled Diagnostic Logs and also added OMS Log Analytics Suite.
I would like to know what is the best way to achieve this above report?
It is possible to do some aggregate report (and even create an alert/notification). Using Log Analytics, you can create a query that searches for any instances when a file is written to your Azure Data Lake Store based on either a common root path, or a file naming:
AzureDiagnostics
| where ( ResourceProvider == "MICROSOFT.DATALAKESTORE" )
| where ( OperationName == "create" )
| where ( Path_s contains "/webhdfs/v1/##YOUR PATH##")
Alternatively, the last line, could also be:
| where ( Path_s contains ".xml")
...or a combination of both.
You can then use this query to create an alert that will notify you during a given interval (e.g. every 24 hours) the number of files that were created.
Depending on what you need, you can format the query these ways:
If you use a common file naming, you can find a match where the path contains said file naming.
If you use a common path, you can find a match where the patch matches the common path.
If you want to be notified of all the instances (not just specific ones), you can use an aggregating query, and an alert when a threshold is reached/exceeded (i.e. 1 or more events):
AzureDiagnostics
| where ( ResourceProvider == "MICROSOFT.DATALAKESTORE" )
| where ( OperationName == "create" )
| where ( Path_s contains ".xml")
| summarize AggregatedValue = count(OperationName) by bin(TimeGenerated, 24h), OperationName
With the query, you can create the alert by following the steps in this blog post: https://azure.microsoft.com/en-gb/blog/control-azure-data-lake-costs-using-log-analytics-to-create-service-alerts/.
Let us know if you have more questions or need additional details.
I will start out by explaining the current domain model. In North America the car manufacturers produce collectively about 3500 distinct trims (Like a 2016 Ford F150 XLT Crew Cab Long Box, or 2016 Audi A3 4dr AWD quattro Sedan)
I have created a Neo4j graph where every trim for every year is a Node (with a label :Vehicle). I also created a second set of nodes of type Feature (all nodes are labeled :Feature). Feature nodes also have a second label that describes the type of feature ( like :MDL, :DIV, :TRIM, :DRIVE, etc.), and features have a value property. So, for the F150 listed above
VehicleId | FeatureType | FeatureValue
----------|-------------|-------------
"380333" | "BOX" | "regular"
"380333" | "DIV" | "Ford"
"380333" | "TYPE" | "Truck
"380333" | "MDL" | "F-150"
"380333" | "CYLINDERS" | "V-8"
"380333" | "TRIM" | "XL"
etc...
All is good. Now, we have a second concept called FVD (short for Flexible Vehicle Description) which is a simple query syntax that describes a set of vehicles using features. For example, the following FVD (+COUNTRY=US+YR=2016+DIV=Mazda+TYPE=Sport Utility) says all US 2016 Mazda Sport Utilities. I have added FVD nodes to the database (with a label :FVD) with INCLUDES relationships to the same Feature Nodes described above.
Finally, my question is, Given that I START at a certain :Vehicle node, how do I find all :FVD's whose :Feature nodes (through the :INCLUDES relationship) are ALL nodes that the :Vehicle node points to as well. NOTE: The :Vehicle node could point to more features than the :FVD node.
If you are thinking, why not create a direct relationship between the :FVD and the :Vehicle. The reason is because the :FVD represents a Set, the vehicles that come in an out of the Set are dynamic throughout the year, which is why I am keeping this abstraction tier.
Sorry for the lengthy post, just trying to explain the situation. I started to play with "Collect", but I got to the point where I had 2 collections, and I needed to know if one collection was completely in another collection.
Try using the all list predicate. The all list predicate will tests whether a predicate holds for all elements of the list.
I think this will work for your example:
MATCH (v:Vehicle{styleId:"380333"})--(vehFeature:Feature)
WITH collect(vehFeature) as vehFeatures
MATCH (fvd:FVD)-[:INCLUDES]->(fvdFeature:Feature)
WITH fvd, vehFeatures, collect(fvdFeature) as fvdFeatures
WHERE all(vf IN vehFeatures WHERE vf IN fvdFeatures)
RETURN fvd
I'm using Parse.com, and have two classes: User and Report. A User may issue several reports during a day, but I'm only interested in the most recent one. However, I need to get all the reports that meet specific criteria, but only the most recent one.
The end result is an array of Reports, where the User is unique on each one, something like this:
ObjectId | ReportedValue | User | CreatedAt
1234 | 100 | aaaa | 2013-05-20T04:23:41.907Z
1235 | 100 | bbbb | 2013-04-29T05:10:41.907Z
1236 | 100 | cccc | 2013-05-20T02:14:41.907Z
1237 | 100 | dddd | 2013-05-19T04:03:41.907Z
So, User aaaa might have 20 reports, but I only need the most recent, for each user. However, I'm searching based on the ReportedValue being 100, and the desired result is the report objects, not the user, so I'd prefer not to go through every user.
Is this possible in Parse?
Consider using another object in the data model to assist with this. It would basically be a container with a relationship to Report. When any new report is saved, a bit of cloud code runs which:
Finds the previous latest Report for the associated user
Removes that report from the container relation
Adds the new report to the container relation
Working this way, your app can make a single, simple, query on the relation to get all of the latest Reports.
From Rest API.... works providing the user's OID is in the ACL segment in the records in the Class you are querying.
in addition to the other predicate of your query, parse can limit the number of returned rows..
--data-urlencode 'limit=1' \
--data-urlencode 'skip=0' \
For the user, if you GET the row from user table for the user you are querying
and the 'token' field value for that user and then with your report query, Set an extra header to the sessionToken value you will get ONLY THAT User's report objects.
-H "X-Parse-Session-Token: pn..." \
you will get just that user's reports
AND
results.size = 1