简体   繁体   English

SharePoint OData 过滤器无效

[英]SharePoint OData filter is not valid

Using this SharePoint OData query:使用此 SharePoint OData 查询:

https://{{siteUrl}}/_api/web/lists('{{ListGuid}}')/items?$top=10&$select=Title,CartNum

I get the follow in my results:我的结果如下:

{
    "d": {
        "results": [
            {
                "__metadata": {
                    "id": "32165487-6548-6548-6548-32165498765432",
                    "uri": "<edited>/_api/Web/Lists(guid'12345678-1234-1234-1234-123456789abc')/Items(1)",
                    "etag": "\"183\"",
                    "type": "SP.Data.JobsItem"
                },
                "Title": "SomeCart",
                "CartNum": "11047975"
            }
        }
    }
}

But if I add a $filter option:但是如果我添加一个$filter选项:

https://{{siteUrl}}/_api/web/lists('{{ListGuid}}')/items?$top=10&$select=Title,CartNum&$filter=CartNum endswith '11047975'

I get this:我明白了:

{
    "error": {
        "code": "-1, Microsoft.SharePoint.Client.InvalidClientQueryException",
        "message": {
            "lang": "en-US",
            "value": "The expression \"CartNum endswith '11047975'\" is not valid."
        }
    }
}

If I change it to:如果我将其更改为:

https://{{siteUrl}}/_api/web/lists('{{ListGuid}}')/items?$top=10&$select=Title,CartNum&$filter=CartNum eq '11047975'

I get this:我明白了:

{
    "error": {
        "code": "-2147024860, Microsoft.SharePoint.SPQueryThrottledException",
        "message": {
            "lang": "en-US",
            "value": "The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator."
        }
    }
}

What am I doing wrong?我究竟做错了什么?

I'm using this MS doc and this OData doc as a reference for the $filter , which clearly state:我正在使用这个MS 文档这个 OData文档作为$filter的参考,这显然是 state:

Operator    Description Example
Logical Operators
Eq  Equal   /Suppliers?$filter=Address/City eq 'Redmond'

No endswith based on official documentation.根据官方文档没有结束。

在此处输入图像描述

When your list data over 5000 items, you can't filter item based on a none-indexed column as throttle limit in SharePoint, you need add the column as indexed so you could filter based on it.当您的列表数据超过 5000 个项目时,您不能基于非索引列过滤项目作为 SharePoint 中的节流限制,您需要将该列添加为索引,以便您可以基于它进行过滤。

https://collab365.community/working-with-large-lists/ https://collab365.community/working-with-large-lists/

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM