Microsoft Graph API is not returning more than 100 object
I tried below query to get "memberof" details of a particular user. However it return only first 100 objects. However User is member of 210 groups. Could you please help me with correct query
https://graph.microsoft.com/v1.0/users/mytestuser#domain.com/memberOf
GET https://graph.microsoft.com/v1.0/users/mytestuser#domain.com/memberOf
The response should contain a "#odata.nextLink" field which can be used to retrieve the next page of the result. An example response could be:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#directoryObjects",
"#odata.nextLink": "https://graph.microsoft.com/v1.0/users/mytestuser#domain.com/memberOf?$top=5&$skiptoken=X%2744537074090001000000000000000014000000B2B64E48AF94EB439F56F5A33CB75C9301000000000000000000000000000017312E322E3834302E3131333535362E312E342E32333331020000000000011C7FEE5EFEFA46459248691C529273D3%27",
"value": [
{ ... }
...
]
}
To retrieve all results we should keep following "#odata.nextLink" of each responses until the response does not contain a "#odata.nextLink" field.
Please have a look at this doc explaining how paging works in Microsoft Graph: https://learn.microsoft.com/graph/paging
It works the same with the /memberOf API
You can use query parameters to customize responses - like so for example get the top 300 - this will return til 300 groups etc
https://graph.microsoft.com/v1.0/users/mytestuser#domain.com/memberOf?$top=300
This is a quick and dirty way, since the memberOf method does not support all OData Query Parameters
https://learn.microsoft.com/en-us/graph/query-parameters
Related
I am working out the structure for a JSON database for an app like onlyFans. Basically, someone can create a club, then inside of that club, there are sections where the creator's posts are shown and another where the club members posts are shown. There is however a filter option where both can be seen.
In order to make option 1 below work, I need to be able to filter based on if isFromCreator=true and at the same time based on timstamp. How can I do this?
Here are the 2 I have written down:
ClubContent
CreatorID
clubID
postID: {isFromCreator: Bool}
OR
creatorPosts
postID: {}
MemeberPosts
postID: {}
Something like the below would be what I want:
ref.child("Content").child("jhTFin5npXeOv2fdwHBrTxTdWIi2").child("1622325513718")
.queryOrdered(byChild: "timestamp")
.queryLimited(toLast: 10)
.queryEqual(toValue: true, childKey: "isFromCreator")
I triedqueryEqual yet it did not return any of the values I know exist with the configuration I specified.
You can use additional resource locations within rules by referencing the parent/child directories specifically and comparing the val() of the respective node structure.
for example:
".write": "data.parent().child('postID').child('isFromCreator').val()"
Just be aware that Security Rules do not filter or process the data in the request, only allow or deny the requested operation.
You can read more about this from the relevant documentation:
https://firebase.google.com/docs/database/security/rules-conditions#referencing_data_in_other_paths
https://firebase.google.com/docs/database/security/core-syntax#rules-not-filters
I'm having an elastic search index which has the following document sample in it :
{
"height": 2824,
"details": {
'gomathi':{'name':'gomathi','age':10},
'janu':{'name':'janu','age':20}
}
}
The data are pushed into elasticsearch dynamically from user. My goal is to fetch all documents that are containing name as gomathi.
Expected output:
Return documents having the 'gomathi' key in 'details' JSON object.
How to solve this?
Thanks in advance.
I assume details is a nested field in mapping. You could use inner_hits in a nested query for the requirement explained.
Please take a look at inner_hits and nested documentation.
I'm working in a MongoDB query with Nodejs and I have a problem that I can't resolve.
Let us supposed we have a lot of documents in Mongo and each document have a tags array
tags: [tag1, tag2, tag3]
Front-end are going to send the parameters and we want to make a query with those... How can I find every document inside Mongo with those tags. The tags can be differents, not all documents have the same tags but I want to pull each document that have almost one of those tags. I don't know if I make myself clear with this but I hope you'll help me.
PD: If the query works, we have more than 13 that I can apply so it needs to be something like dynamically query o something.
Regards
This is where the mongodb's aggregate function comes in play
lets say there is a database called books and we want to get books that contain lets say ['fantasy', 'sci-fi'] in its genres
db.book.aggregate([{
$match:{
genres:{
$in:['fantasy', 'sci-fi']
}
}
}])
this will get the result you want, finding all the books that contain either fantasy, or scifi
db.book.aggregate([{
$match:{
genres:{
$all:['fantasy', 'sci-fi']
}
}
}])
This will get all the books that have genres with both fantasy and sf
db.book.aggregate([{
$match:{
genres:{
$nin:['fantasy', 'sci-fi']
}
}
}])
This will fetch all the books that don't have these values
generate an $or condition in your code according to the parameters:
let or_array = [];
params.forEach(params, (tag_param) => {
or_array.push({tags: tag_param})
});
let or_cond = {$or: or_array};
now we just need a simple find query to retrieve the documents:
let results = model.find(or_cond);
results should contain the wanted documents.
** note that $or requires a none empty array so you should validate at least one parameter is received from the client side.
Follwing statement find all profiles that has Facebook or twitter and this works:
$filter=SocialAccounts/any(x: search.in(x, 'Facebook,Twitter'))
But I cant find any samples for finding all that has both Facebook and twitter. I tried:
$filter=SocialAccounts/all(x: search.in(x, 'Facebook,Twitter'))
But this is not valid query.
Azure Search does not support the type of ‘all’ filter that you’re looking for. Using search.in with ‘all’ would be equivalent to using OR, but Azure Search can only handle AND in the body of an ‘all’ lambda (which is equivalent to OR in the body of an ‘any’ lambda).
You might try a workaround like this:
$filter=tags/any(t: t eq 'Facebook') and tags/any(t: t eq 'Twitter')
However, this isn't actually equivalent to using all with search.in. The query as expressed using all is matching documents where every social account is strictly either Facebook or Twitter. If any other social account is present, the document won’t match. The workaround doesn’t have this property. A document must have at least Facebook and Twitter in order to match, but not exclusively those. This is certainly a valid scenario; it just isn't the same as using all with search.in, which was the original question.
No matter how you try to rewrite the query, you won’t be able to express an equivalent to the all query. This is a limitation due to the way Azure Search stores collections of strings and other primitive types in the inverted index.
Please vote on user voice to help prioritize:
https://feedback.azure.com/forums/263029-azure-search/suggestions/37166749-efficient-way-to-express-a-true-all
A possible workaround is to use the new Complex Types feature, which does allow more expressive filters inside lambda expressions. For example, if you model tags as objects with a single value property instead of as a collection of strings, you should be able to execute a filter like this:
$filter=tags/all(t: search.in(t/value, 'Facebook,Twitter'))
In the REST API, you'd define tags like this:
{
"name": "myindex",
"fields": [
...
{
"name": "tags",
"type": "Collection(Edm.ComplexType)",
"fields": [
{ "name": "value", "type": "Edm.String", "filterable": true }
]
}
]
}
Note that this feature is in preview at the time of this writing, but will be generally available (and publicly documented) soon.
Instead keys and IDs alone, I want to get all the docs via couch api. I have tried with GET "http://localhost:5984/db-name/_all_docs" but it returned
{
"total_rows":4,
"offset":0,
"rows":[
{"id":"11","key":"11","value":{"rev":"1-a0206631250822b37640085c490a1b9f"}},
{"id":"18","key":"18","value":{"rev":"30-f0798ed72ceb3db86501c69ed4efa39b"}},
{"id":"3","key":"3","value":{"rev":"15-0dcb22bab2b640b4dc0b19e07c945f39"}},
{"id":"6","key":"6","value":{"rev":"4-d76008cc44109bd31dd32d26ba03125d"}}
]
}
From the documentation
for the below request it will send the data as we expected but it requires set of keys in request.
POST /db/_all_docs HTTP/1.1
{
"keys" : [
"11",
"18"
]
}
Thanks in advance.
The _all_docs endpoint is actually just a system-level view that uses the _id field as the index. Thus, any parameters that you can use for views also apply here.
If you read the documentation further, you'll find that adding the parameter include_docs=true to your view will include the original documents in the results. The documents will be added as the doc field alongside id, value and rev.