Microsoft Graph Search returning duplicates - microsoft-graph-api

I am querying https://graph.microsoft.com/v1.0/search/query with the following payload:
{
"requests": [
{
"entityTypes": [
"listItem"
],
"query": {
"queryString": "uniqueid:925211fd-fc7e-4ed8-95fb-0bd00f378e8b"
},
"trimDuplicates": true,
"fields": [
"uniqueid",
"originalpath"
]
}
]
}
Searching for UniqueID I would expect a single result, but instead I get the same item twice:
{
"value": [
{
"searchTerms": [],
"hitsContainers": [
{
"hits": [
{
"hitId": "925211fd-fc7e-4ed8-95fb-0bd00f378e8b",
"rank": 1,
"summary": "",
"resource": {
"#odata.type": "#microsoft.graph.listItem",
"fields": {
"uniqueid": "{925211fd-fc7e-4ed8-95fb-0bd00f378e8b}",
"originalpath": "https://tenant.sharepoint.com/sites/POC/POC Docs/Employee Contracts/JohnD Employee Contract.docx"
}
}
},
{
"hitId": "925211fd-fc7e-4ed8-95fb-0bd00f378e8b",
"rank": 2,
"summary": "",
"resource": {
"#odata.type": "#microsoft.graph.listItem",
"fields": {
"uniqueid": "{925211fd-fc7e-4ed8-95fb-0bd00f378e8b}",
"originalpath": "https://tenant.sharepoint.com/sites/POC/POC Docs/Employee Contracts/JohnD Employee Contract.docx"
}
}
}
],
"total": 2,
"moreResultsAvailable": false
}
]
}
],
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.searchResponse)"
}
I get duplicate results with other queries as well. It is not limited to this specific file. If I do the same search in SharePoint I only get a single result as expected.
Am I doing something wrong, or is this a bug?

per my test, unfortunately, I cannot reproduce your issue. In my tests, I can use the following Graph API well and return only one result:
https://graph.microsoft.com/v1.0/search/query
My test result:
I suggest you can create a feedback on this issue, more professional will help you. Thank you for your understanding.
Feedback: https://feedbackportal.microsoft.com/feedback/forum/ebe2edae-97d1-ec11-a7b5-0022481f3c80

Related

Spell corrections not working when refining queries with aggregations

I'm searching for list items using the /search/query endpoint of MS Graph. I want to use aggregations and spell checking. This is my request
{
"requests": [
{
"entityTypes": [
"listItem"
],
"query": {
"queryString": "inspring"
},
"fields": [
"title"
],
"aggregations": [
{
"field": "fileType",
"size": 20,
"bucketDefinition": {
"sortBy": "count",
"isDescending": "true",
"minimumCount": 0
}
}
],
"queryAlterationOptions": {
"enableModification": true
}
}
]
}
It returns no results, since the search term was not spell checked and modified:
{
"value": [
{
"searchTerms": [
"inspring"
],
"hitsContainers": [
{
"total": 0,
"moreResultsAvailable": false
}
]
}
],
"#odata.context": "https://graph.microsoft.com/beta/$metadata#Collection(microsoft.graph.searchResponse)"
}
However, when I remove the aggregations and use the following request, it works:
{
"requests": [
{
"entityTypes": [
"listItem"
],
"query": {
"queryString": "inspring"
},
"fields": [
"title"
],
"queryAlterationOptions": {
"enableModification": true
}
}
]
}
Response:
{
{
"value": [
{
"searchTerms": [
"inspiring"
],
"hitsContainers": [
{
"hits": [...],
"total": 64,
"moreResultsAvailable": true
}
],
"queryAlterationResponse": {
"originalQueryString": "inspring",
"queryAlteration": {
"alteredQueryString": "inspiring",
"alteredHighlightedQueryString": "inspiring",
"alteredQueryTokens": [
{
"offset": 0,
"length": 8,
"suggestion": "inspiring"
}
]
},
"queryAlterationType": "modification"
}
}
],
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.searchResponse)"
}
How do I have to change my request to make query alterations work with aggregations?

Unexpected microsoft external search aggregation values

We have an Microsoft Search instance for crawling one custom app : https://learn.microsoft.com/en-us/microsoftsearch/connectors-overview
Query & display is working as expected but aggregation provides wrong results
query JSON : https://graph.microsoft.com/v1.0/search/query
select title + submitter and aggregation on submitter
"fields": [
"title",
"submitter"
],
"aggregations": [
{
"field": "submitter",
"size": 1,
"bucketDefinition": {
"sortBy": "keyAsString",
"isDescending": true,
"minimumCount": 0
}
}
]
JSON response
submitter property is correctly returned with Firstname Lastname on row 0 but aggregate is lowercase and middle space trimmed firstnamelastname
"hitsContainers": [
{
"total": 1,
"moreResultsAvailable": false,
"hits": [
{
"hitId": "xxxx",
"contentSource": "ConnectionId",
"rank": 1,
"summary": "New service / <c0>business</c0> <c0>model</c0> <c0>design</c0> <ddd/>",
"resource": {
"#odata.type": "#microsoft.graph.externalConnectors.externalItem",
"properties": {
"title": "New service / business model design",
"submitter": "Firstname Lastname"
}
}
}
],
"aggregations": [
{
"field": "submitter",
"buckets": [
{
"key": "firstnamelastname",
"count": 1,
"aggregationFilterToken": "\"ǂǂ696c736573706f656c73747261\""
}
]
}
]
}
]
reproducible in Microsoft Graph Explorer (a bit obfuscated)
result with space
aggregation concatenated in lowercase
Rootcause has been identified as submitter property wasn't created with flag refinable
{
"name": "submitter",
"type": "String",
"isSearchable": "true",
"isQueryable": "true",
"isRetrievable": "true"
"isRefinable": "false"
}
as a consequence, output was incorrect.
testing with refinable = true provides correct aggregation value (1 = non refinable, 2 = refinable).
small note : refinable properties can't be searchable

Microsoft graph user delta - manager issue

When I try to get users via the delta endpoint:
https://graph.microsoft.com/v1.0/users/delta?$select=id,displayName,manager
The returned response will contain some users with the manager property defined, as expected:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(id,displayName,manager)",
"#odata.nextLink": "https://graph.microsoft.com/v1.0/users/delta?$skiptoken=[token]",
"value": [
{
"displayName": "user1",
"id": "id1"
},
{
"displayName": "user2",
"id": "id2",
"manager#delta": [
{
"#odata.type": "#microsoft.graph.user",
"id": "managerId1"
}
]
},
{
"displayName": "user3",
"id": "id3"
},
// etc
]
}
However when I then query the returned nextLink to get the second page, the same set of users are returned as the first page, and this time without any managers. Also note that the #odata.context value has changed now too:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users",
"#odata.nextLink": "https://graph.microsoft.com/v1.0/users/delta?$skiptoken=[token]",
"value": [
{
"displayName": "user1",
"id": "id1"
},
{
"displayName": "user2",
"id": "id2"
},
{
"displayName": "user3",
"id": "id3"
},
... etc
]
}
When I remove the displayName property, so am only selecting for id and manager, the paging seems to work correctly:
https://graph.microsoft.com/v1.0/users/delta?$select=id,manager
The issue has been reproduced when including the userPrincipalName property in the $select too.

DWG to DGN conversion using Design Automation API

Is there any possibility for conversion from dwg to dgn using forge design automation api? If yes then what will be the best way to do that? Any suggestion would be helpful.
Yes, you can use the -DGNEXPORT command in your script to accomplish this.
I was trying to get a concrete codes for this question as it requires some tricks and support of seed file on Design Automation. By engineer team's help, now it is working.
Assume we test with Postman. If you are working with v2 of Design Automation, the scripts below demo the usage.
Activity:
{
"HostApplication": "",
"RequiredEngineVersion": "23.1",
"Parameters": {
"InputParameters": [{
"Name": "HostDwg",
"LocalFileName": "$(HostDwg)"
}],
"OutputParameters": [{
"Name": "Result",
"LocalFileName": "result.dgn"
}]
},
"Instruction": {
"CommandLineParameters": null,
"Script":"(command \"_-DGNEXPORT\" \"_V8\" (strcat (getvar \"DWGPREFIX\")
\"result.dgn\") \"_Master\" \"Standard\" (strcat (getvar \"LOCALROOTPREFIX\")
\"Template\\\\V8-Imperial-Seed3D.dgn\"))\n"
},
"Version": 1,
"Id": "CreateActByLISP"
}
WorkItem:
{
"#odata.type": "#ACES.Models.WorkItem",
"Arguments": {
"InputArguments": [
{
"Resource": "http://forge-test.oss-cn-shanghai.aliyuncs.com/test.dwg",
"Name": "HostDwg",
"StorageProvider": "Generic"
}
],
"OutputArguments": [
{
"Name": "Result",
"StorageProvider": "Generic",
"HttpVerb": "POST",
"Resource": null
}
]
},
"ActivityId": "CreateActByLISP",
"Id": ""
}
If working with v3 of Design Automation, the script would be as below. Note: the engine needs 23.1 (Autodesk.AutoCAD+23_1)
Activity
{
"commandLine": [
"$(engine.path)\\accoreconsole.exe /i $(args[HostDwg].path) /s $(settings[script].path)"
],
"parameters": {
"HostDwg": {
"verb": "get",
"description": "Host drawing to be loaded into acad.",
"localName": "$(HostDwg)"
},
"Result": {
"verb": "post",
"description": "Results",
"localName": "result.dgn"
}
},
"engine": "Autodesk.AutoCAD+23_1",
"appbundles": [],
"settings": {
"script": {
"value": "(command \"_-DGNEXPORT\" \"_V8\" (strcat (getvar \"DWGPREFIX\") \"result.dgn\") \"_Master\" \"Standard\" (strcat (getvar \"LOCALROOTPREFIX\") \"Template\\\\V8-Imperial-Seed3D.dgn\"))\n"
}
},
"description": "PlotToPdf for all layouts.",
"id": "myexportdgn"
}
WorkItem:
{
"activityId": "{{your nick name}}.myexportdgn+{{activity alias}}",
"arguments": {
"HostDwg": {
"url": "http://forge-test.oss-cn-shanghai.aliyuncs.com/test.dwg"
},
"Result": {
"verb": "put",
"url": "<your upload url>"
}
}
}

$ dont work with JsonPath

I Post one Json with RestAssured and After I need to verify that all fields are stored in the database with the correct values.My Json is :
{
"id": "1",
"name": "name1",
"description": "description1",
"source": "source1",
"target": "target1",
"domain": "PM",
"transformation_rules": [
{
"name": "name2",
"filters": [
{
"object": "object1",
"pattern": "pattern1"
}
],
"operations": [
{
"pattern": "pattern2",
"replacement": "replacement1"
}
]
},
{
"name": "name3",
"filters": [
{
"object": "object2",
"pattern": "pattern2"
}
],
"operations": [
{
"pattern": "pattern3",
"replacement": "replacement2"
},
{
"pattern": "pattern3",
"replacement": "replacement3"
},
{
"pattern": "pattern4",
"replacement": "replacement4"
}
]
}
],
"conflict_policy": "ACCEPT_SOURCE"
}
So, I have :
responseGet = RestAssured.given().contentType(ContentType.JSON).when().get(urlApi + "/" + id);
My first verification is :
responseGet.then().body("$[0]['id']", equalTo("1"));
to verify that the field "id" equals to 1 it doesn't execute well and I change to :
responseGet.then().body("$.id", equalTo("1"));
and the same result ---> fails
Please, can you give me your suggestions for testing all the Json ?
Just for information, I try to apply : https://github.com/json-path/JsonPath.
Thank you very much in Advance,
Best Regards,
You can directly use jsonPath() for checking this:
For example:
responseGet.body().jsonPath().getString("id").equals("1");
For reading JsonPath

Resources