Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated advance search for files in readme #66

Merged
merged 1 commit into from
May 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,14 +459,16 @@ in
the [documentation here](https://docs.imagekit.io/api-reference/media-api/list-and-search-files#list-and-search-file-api)
can be passed with the correct values to get the results.

#### Applying Filters
Filter out the files by specifying the parameters.

```Python
from imagekitio.models.ListAndSearchFileRequestOptions import ListAndSearchFileRequestOptions

options = ListAndSearchFileRequestOptions(
type='file',
sort='ASC_CREATED',
path='/',
search_query="created_at >= '2d' OR size < '2mb' OR format='png'",
file_type='all',
limit=5,
skip=0,
Expand All @@ -485,6 +487,29 @@ print(result.response_metadata.raw)
print(result.list[0].file_id)
```

#### Advance Search
In addition, you can fine-tune your query by specifying various filters by generating a query string in a Lucene-like syntax and providing this generated string as the value of the `search_query`.

```Python
from imagekitio.models.ListAndSearchFileRequestOptions import ListAndSearchFileRequestOptions

options = ListAndSearchFileRequestOptions(
search_query="createdAt >= '2d' OR size < '2mb' OR format='png'",
)

result = imagekit.list_files(options=options)

# Final Result
print(result)

# Raw Response
print(result.response_metadata.raw)

# print the first file's ID
print(result.list[0].file_id)
```
Detailed documentation can be found here for [advance search queries](https://docs.imagekit.io/api-reference/media-api/list-and-search-files#advanced-search-queries).

**2. Get File Details**

Accepts the file ID and fetches the details as per
Expand Down
Loading