简体   繁体   English

Microsoft Graph API 搜索 function 无法按预期工作

[英]Microsoft Graph API search function doesn't work as expected

I am trying to do a basic search for displayName of my organization using the Microsoft Graph API.我正在尝试使用 Microsoft Graph API 对我的组织的 displayName 进行基本搜索。

The problem is, the search function doesn't work as expected.问题是,搜索 function 没有按预期工作。 Based on my tests the search function doesn't actually do fuzzy searching properly, the logic is obviously based on startsWith and endsWith and not contains.根据我的测试,搜索 function 实际上并没有正确进行模糊搜索,逻辑显然基于startsWith和endsWith而不包含。 For my needs this doesn't suffice because my organization's displayName contains both Korean name and English name.对于我的需要,这还不够,因为我的组织的 displayName 包含韩文名称和英文名称。 For example:例如:

A user with displayName: 이선빈(Annie Lee)具有 displayName 的用户:이선빈(Annie Lee)

https://graph.microsoft.com/v1.0/users/?$search="displayName:이선" returns the correct result. https://graph.microsoft.com/v1.0/users/?$search="displayName:이선"返回正确的结果。 https://graph.microsoft.com/v1.0/users/?$search="displayName:Annie" returns no result. https://graph.microsoft.com/v1.0/users/?$search="displayName:Annie"不返回任何结果。 https://graph.microsoft.com/v1.0/users/?$search="displayName:Lee" returns no result https://graph.microsoft.com/v1.0/users/?$search="displayName:Lee )" returns the correct result https://graph.microsoft.com/v1.0/users/?$search="displayName:Lee"没有返回结果https://graph.microsoft.com/v1.0/users/?$search="displayName :Lee )" 返回正确的结果

What was the point of updating the API with the search function if actual fuzzy searching wasn't supported?如果不支持实际的模糊搜索,那么使用搜索 function 更新 API 有什么意义? $filter using startsWith and endsWith operator has been supported since the beginning, but the reason why people wanted the $search function was to be able to actually query for displayName properly using a contains function.从一开始就支持使用startsWith 和endsWith 运算符的$filter,但是人们想要$search function 的原因是能够实际使用包含function 正确查询displayName。 It seems Microsoft essentially "added" a search function when functionally it's basically the $filter with startsWith and endsWith query.似乎微软本质上“添加”了一个搜索 function 当功能上它基本上是 $filter 与 startsWith 和 endsWith 查询。

Am I missing something with the API?我是否缺少 API 的东西? Is there a possible workaround in my case?在我的情况下是否有可能的解决方法?

I'm the PM for the Advanced Query Parameters .我是高级查询参数的 PM。
$search tokenization considers the parenthesis character ( as a token delimiter, so 이선빈(Annie Lee) is split into these tokens: $search 标记化将括号字符(作为标记分隔符,因此이선빈(Annie Lee)被拆分为以下标记:

 - 이선빈
 - (
 - Annie
 - Lee
 - )

It is very weird that your queries searching for "Annie" or "Lee" do not return any result.您搜索“Annie”或“Lee”的查询没有返回任何结果,这很奇怪。 We tried on our end, and we cannot repro.我们尽了最大努力,但我们无法复制。
Can you share the request-id for your failed search to help us debugging this issue?您能否分享搜索失败的request-id以帮助我们调试此问题?

Note : we cannot implement a "true" contains algorithm due to performance reasons, we believe that tokenization search is the best compromise.注意:由于性能原因,我们无法实现“真实”包含算法,我们认为标记化搜索是最好的折衷方案。

PS: we updated the documentation to highlight your specific case: https://docs.microsoft.com/en-us/graph/search-query-parameter#using-search-on-directory-object-collections PS:我们更新了文档以突出显示您的具体案例: https://docs.microsoft.com/en-us/graph/search-query-parameter#using-search-on-directory-object-collections

Thanks for the clarification in your last comment.感谢您在上次评论中的澄清。
You can solve the issue by taking advantage of $search behavior for non-tokenized properties: it will default to startsWith operator.您可以利用非标记属性的$search行为来解决该问题:它将默认为startsWith运算符。

Your final query should look like this:您的最终查询应如下所示:
/users?$search="displayName:<INPUT>" OR "givenName:<INPUT>" OR "surname:<INPUT>"

Let me know if this works for you.让我知道这是否适合您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Microsoft Graph API - 创建联系人不起作用 - Microsoft Graph API - Create Contact doesn't work 具有选择和筛选条件的 Microsoft Graph API 用户搜索不会搜索具有给定条件的用户 - Microsoft Graph API user search with Select & Filter condition doesn't search users with given condition 通过Microsoft Graph API在Azure AD中邀请用户无效 - Inviting a User in Azure AD through Microsoft Graph API doesn't work Microsoft Graph OData查询参数$ expand似乎不起作用 - Microsoft Graph OData query parameter $expand doesn't seem to work Microsoft graph api 下载文件内容不返回 不返回下载 URL - Microsoft graph api download file content doesn't return doesn't return download URL 使用Microsoft图形API工作帐户发送电子邮件 - Sending email with Microsoft graph API work account 工作帐户的 microsoft graph api 错误 - microsoft graph api error for work accounts Microsoft Graph API redirect_uri不允许查询字符串 - Microsoft Graph API redirect_uri doesn't allow query strings Microsoft Graph AD 用户或人员 API 来搜索所有用户? - Microsoft Graph AD Users or people API to search all users? Microsoft Graph API 是否适用于 Office 365 家庭版订阅? - Does Microsoft Graph API work with Office 365 family subscription?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM