Skip to content

Commit d773ebc

Browse files
jacalataclaude
andcommitted
Limit filter docs to confirmed behavior
Remove the operator and field scope claims, the case-sensitivity paragraph, the like operator table, the view filter section, the In list section and the version-specific encoding and wildcard claims. Keep the comma failure, the asterisk workaround, and the Has and CaseInsensitiveEquals operator rows. Co-Authored-By: Claude Code <noreply@anthropic.com>
1 parent d1f4a04 commit d773ebc

1 file changed

Lines changed: 26 additions & 87 deletions

File tree

‎docs/filter-sort.md‎

Lines changed: 26 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,23 @@ then pass the object to your endpoint as a parameter.
1010

1111
## Available endpoints and fields
1212

13-
You can use the TSC library to filter and sort the results of any endpoint whose `get`
14-
method accepts a `RequestOptions` object, and the endpoints that support the `.filter()` and
15-
`.order_by()` shorthand: custom views, data sources, flow runs, flows, groups, group sets,
16-
jobs, linked tasks, metrics, projects, users, views, virtual connections, and workbooks.
13+
You can use the TSC library to filter and sort the following endpoints:
1714

18-
The fields you can filter or sort on are the members of `RequestOptions.Field`, for example
19-
`CreatedAt`, `LastLogin`, `Name`, `OwnerName`, `SiteRole`, `Tags`, and `UpdatedAt`.
15+
* Users
16+
* Datasources
17+
* Workbooks
18+
* Views
19+
20+
For the above endpoints, you can filter or sort on the following
21+
fields:
22+
23+
* CreatedAt
24+
* LastLogin
25+
* Name
26+
* OwnerName
27+
* SiteRole
28+
* Tags
29+
* UpdatedAt
2030

2131
**Important**: Not all of the fields are available for all endpoints. For more information, see the [REST
2232
API help](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_filtering_and_sorting.htm).
@@ -42,37 +52,25 @@ The operator can be any of the following:
4252
* Has
4353
* CaseInsensitiveEquals
4454

45-
Not every operator is supported on every field. In particular, the REST API supports
46-
`Has` (substring search) only for jobs, and `CaseInsensitiveEquals` only on user name,
47-
group name, and group set name. See the per-endpoint field tables in the [REST
55+
Not every operator is supported on every field. See the per-endpoint field tables in the [REST
4856
API help](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_filtering_and_sorting.htm).
4957

5058
### Value criteria
5159

52-
The value that you want to filter on. This can be any valid string. Field names and operator
53-
names are case-sensitive. Whether a value is case-sensitive depends on the field. In testing,
54-
`Equals` on the name of a workbook, data source, project, or user, and on a workbook's content
55-
URL, ignored case. `Equals` on a group name was case-sensitive on Tableau Server. Where the
56-
field supports it, use `CaseInsensitiveEquals` to ignore case regardless.
57-
58-
Pass values as plain strings. For REST API version 3.7 and later, TSC URL-encodes the
59-
query string for you, so do not percent-encode values yourself.
60+
The value that you want to filter on. This can be any valid string.
6061

6162
### Special characters in filter values
6263

6364
The REST API does not accept a comma (`,`) in a filter value, because it uses commas to
64-
separate expressions. This is true even if the comma is URL-encoded, and putting a backslash
65-
in front of it does not escape it. A filter value that contains a comma fails with a
66-
`400065: Bad Request` error:
65+
separate expressions. A filter value that contains a comma fails with a `400065` error.
66+
Percent-encoding the comma or putting a backslash in front of it does not help.
6767

6868
```py
6969
# Fails: the workbook name contains a comma
7070
workbooks = server.workbooks.filter(name="Sales, Q1 & Q2")
7171
```
7272

73-
From REST API 3.7, an ampersand (`&`) works when you use TSC, because TSC URL-encodes the query
74-
string. On earlier versions, or if you build the request yourself, encode the ampersand as `%26`:
75-
a literal `&` ends the `filter` parameter and the server sees a truncated filter.
73+
An ampersand (`&`) in a name is matched as typed.
7674

7775
To find an item whose name contains a comma, replace the comma with an asterisk (`*`). The
7876
asterisk acts as a wildcard, so the following filter finds the workbook named
@@ -83,7 +81,7 @@ for workbook in server.workbooks.filter(name="Sales* Q1 & Q2"):
8381
print(workbook.name, workbook.id)
8482
```
8583

86-
Because a wildcard matches any character, the filter can return more than one item. Check
84+
Because `*` matches any run of characters, the filter can return more than one item. Check
8785
the results on the client side if you need an exact match:
8886

8987
```py
@@ -96,50 +94,10 @@ This works because `Equals` treats `*` as a wildcard (see [Wildcard searches](#w
9694

9795
### Wildcard searches
9896

99-
The REST API supports wildcard searches (starts with, ends with, and contains) starting in
100-
Tableau Cloud May 2023 and Tableau Server 2022.1.14. The REST API documents these searches
101-
through its `like` operator, and only on selected name fields: user name, user
102-
friendlyName, group name, and group set name. Other fields support exact matches only.
103-
104-
In practice, `*` also acts as a wildcard in the value of an `Equals` filter on other name
105-
fields, at the start, end, or middle of the value. In testing this worked for workbook names on
106-
Tableau Cloud and for project names on a Tableau Server that supports REST API 3.31. For example,
107-
`server.workbooks.filter(name="Sales*")` returns workbooks whose names start with `Sales`,
108-
`name="*2026"` returns names that end with `2026`, and `name="*Q1 *"` returns names that contain
109-
`Q1 `. The match ignores letter case where `Equals` does. The REST API
110-
documentation does not describe this behavior or say which versions support it, so confirm it on
111-
your Tableau Server version and field before you rely on it. The
112-
`like` operator is rejected on workbook names (`400 Bad Request`), as are `CaseInsensitiveEquals`
113-
and `Has`.
114-
115-
For example, to search for the string `marketing-example`, the REST API documentation
116-
gives the following filter expressions:
117-
118-
| Search | REST API filter expression |
119-
| --- | --- |
120-
| Starts with | `name:like:mark*` |
121-
| Ends with | `name:like:*-ample` |
122-
| Contains | `name:like:mark*ex*` |
123-
124-
TSC does not define a `RequestOptions.Operator` value for `like`, and there are no
125-
`contains`, `startswith`, or `endswith` operators. A Django style filter such as
126-
`name__like="mark*"` raises a `ValueError`.
127-
128-
### View filters follow different rules
129-
130-
The rules above apply to the `filter` query parameter that `RequestOptions.filter` and the
131-
Django style filters build. View filters that you set with `vf()` on export options such as
132-
`CSVRequestOptions` or `PDFRequestOptions` are sent as `vf_<column>=<value>` parameters, and
133-
the server reads their values differently:
134-
135-
- A comma separates alternatives, so `vf("Region", "East,West")` matches `East` or `West`.
136-
To match a literal comma, escape it with a backslash: `vf("Name", "Rock\\, Paper")`.
137-
- `*` and `%` are literal characters, not wildcards.
138-
- Ampersands and other characters are passed through as data. TSC URL-encodes the value, so
139-
`vf("Client", "Smith & Sons")` sends the ampersand intact.
140-
141-
For the server-side rules, see [Filter query views](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_filtering_and_sorting.htm#Filter-query-views)
142-
in the REST API documentation.
97+
In a filter value, `*` matches any run of characters, including none. For example,
98+
`server.workbooks.filter(name="Sales*")` returns workbooks whose names start with `Sales`. This
99+
was tested for workbook names on Tableau Cloud. Confirm the behavior on your Tableau Server
100+
version before you rely on it for other fields.
143101

144102
### Filtering example - RequestOptions
145103

@@ -155,25 +113,6 @@ matching_workbooks, pagination_item = server.workbooks.get(req_option)
155113
print(matching_workbooks[0].owner_id)
156114
```
157115

158-
### Matching one of several values
159-
160-
The `In` operator matches items whose field equals any value in a list:
161-
162-
```py
163-
req_option = TSC.RequestOptions()
164-
req_option.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name,
165-
TSC.RequestOptions.Operator.In,
166-
['Superstore', 'Sales Dashboard']))
167-
matching_workbooks, pagination_item = server.workbooks.get(req_option)
168-
```
169-
170-
Names that contain spaces or ampersands work in a list. The server separates the entries with
171-
commas, so a value that contains a comma is split into separate entries and does not match
172-
the item it names. The request does not fail. See
173-
[Special characters in filter values](#special-characters-in-filter-values).
174-
175-
The Django style equivalent is `server.workbooks.filter(name__in=['Superstore', 'Sales Dashboard'])`.
176-
177116
## Sorting
178117

179118
To sort on a field, you need to specify the field name and the direction criteria for the sort order.

0 commit comments

Comments
 (0)