Forum Discussion
JGedney
Feb 22, 2024Copper Contributor
search/codesearchresults not able to get more than 2000 results?
when I send a POST API request to
"https://MYAZUREINSTANCE/tfs/COLLECTION/MYPROJECT/_apis/search/codesearchresults?api-version=7.0"
with this payload
{
"searchText": "ext:dll",
"$skip": 1000,
"$top": 1000,
"filters": [
{
"name": "ProjectFilters",
"values": [
"MYPROJECT"
]
},
{
"name": "RepositoryFilters",
"values": [
"$/MYPROJECT"
]
}
],
"searchFilters": {
"ProjectFilters": [
"MYPROJECT"
],
"RepositoryFilters": [
"$/MYPROJECT"
]
}
}
the API returns the file data correctly.
but I have more than 2000 such files.
if I set
"$skip": 2000,
it returns an error stating that the $skip must be between 0 and 1000....
How do I get the rest of the files?
1 Reply
Sort By
Seems not but some workaround:
- Pagination with Filters:
- Use additional filters (e.g., file extensions, paths, or timestamps) to narrow down the results into smaller subsets.
- For example, you could filter by specific file types or directories and then query each subset separately.
- Order and Filter by Unique Attributes:
- Sort the results by a unique attribute (e.g., file name or modification timestamp).
- Use the last value from the previous query as a filter for the next query. For example:
- Query 1: $skip=0, $top=1000
- Query 2: Filter results where the unique attribute is greater than the last value from Query 1.
- Batch Queries:
- Divide the search into multiple queries by specifying different repositories or branches if applicable.
- This approach allows you to retrieve results in smaller, manageable batches.
- Custom Script for Iterative Retrieval:
- Write a script to automate the process of querying the API iteratively, applying filters or sorting to retrieve all results in chunks.