Skip to content

Commit

Permalink
Merge pull request #66 from imagekit-developer/IK-1400
Browse files Browse the repository at this point in the history
updated advance search for files in readme
  • Loading branch information
ahnv authored May 13, 2024
2 parents 694c7b9 + ce86aff commit 43f8922
Showing 1 changed file with 26 additions and 1 deletion.
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

0 comments on commit 43f8922

Please sign in to comment.