为Microsoft Graph创建一个过滤查询,该查询的工作原理等同于“包含"查询. [英] Create a filter query for Microsoft Graph that works equivalent to "contains"

查看:53
本文介绍了为Microsoft Graph创建一个过滤查询,该查询的工作原理等同于“包含"查询.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为 Microsoft Graph API 创建一个 $ filter 查询,该查询将搜索字符串(用户的显示名称)中的特定单词.

I need to create a $filter query for the Microsoft Graph API that searches for a specific word in a string (the display name of users).

例如,我希望能够找到其名称中具有"Esteban" 的所有用户:

For example I'd want to be able to find all users that have "Esteban" in their names:

路易斯·埃斯特万
阿方斯·埃斯特万
埃斯特万·路易斯
阿方斯·埃斯特万·路易斯

Luis Esteban
Alphonse Esteban
Esteban Luis
Alphonse Esteban Luis

以下查询有效,但仅返回名称中以"Esteban" 开头的用户,而不返回包含"Esteban" 的用户:

The following query works, but only returns users that start with "Esteban" in their names, not users that contain "Esteban":

https://graph.microsoft.com/v1.0/users?$filter=startswith(displayName,'Esteban')

我也尝试使用 contains 而不是 startswith ,但是它给出了错误响应:

I also tried using contains instead of startswith, but it gives an error response:

{错误":{代码":"Request_BadRequest",消息":发现了一个名称为'contains'的未知函数.这也可能是对导航属性的关键查找,这是不允许的.," innerError:{" request-id:" e5ed5c30-4e62-4497-8976-1d38167e759d," date:" 2018-09-13T23:17:17}}}

{ "error": { "code": "Request_BadRequest", "message": "An unknown function with name 'contains' was found. This may also be a key lookup on a navigation property, which is not allowed.", "innerError": { "request-id": "e5ed5c30-4e62-4497-8976-1d38167e759d", "date": "2018-09-13T23:17:17" } } }

即使 Microsoft Graph文档表示他们支持 OData 4.0 ,他们也这样说:

And even though the Microsoft Graph docs say they support OData 4.0, they also say this:

当前在任何Microsoft Graph资源上均不包含contains字符串运算符."

"The contains string operator is currently not supported on any Microsoft Graph resources."

我还尝试了

I also tried other commands given by the OData documentation and the construction rules that are supposed to be supported by filter and other query parameters.

我特别尝试了以下命令的组合:

In particular I tried combinations of these commands:


开始以
结尾indexof
子串

startswith
endswith
indexof
substring

但没有成功.看来 MS Graph API 除了 startswith 之外,什么都不支持.

but to no success. It seems the MS Graph API has no support for anything except startswith whatsoever.

我尝试了API的v1.0和beta端点.

I tried both v1.0 and the beta endpoints of the API.

还有其他方法吗? OData 4.0 命令和/或 MS Graph API 支持的查询参数的某种智能组合,可以实现等效搜索要包含?

Is there any other way, some smart combination of OData 4.0 commands and/or query parameters supported by the MS Graph API, that allows a search equivalent to contains?

PS:您可以使用图形资源管理器推荐答案

您知道,Graph API现在不支持您的要求.我的建议是先获取用户列表,然后再进行内存过滤.这种方式也适用于其他不受支持的Graph API.

As you know, Graph API doesn't support your requirement now. My suggestion is to get the user list first and then do in-memory filter. This way also applicable to other no-supported Graph API.

同时,请确保对用户语音中的filter-to-specify-end"rel =" nofollow noreferrer>现有功能请求a>或提交一个新的.

Meanwhile, make sure to vote up the existing feature request in User Voice or submit a new one.

这篇关于为Microsoft Graph创建一个过滤查询,该查询的工作原理等同于“包含"查询.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆