Skip to content

Commit ce86aff

Browse files
ANKUR DWIVEDIANKUR DWIVEDI
ANKUR DWIVEDI
authored and
ANKUR DWIVEDI
committed
updated advance serch for files in readme
1 parent 694c7b9 commit ce86aff

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,14 +459,16 @@ in
459459
the [documentation here](https://docs.imagekit.io/api-reference/media-api/list-and-search-files#list-and-search-file-api)
460460
can be passed with the correct values to get the results.
461461

462+
#### Applying Filters
463+
Filter out the files by specifying the parameters.
464+
462465
```Python
463466
from imagekitio.models.ListAndSearchFileRequestOptions import ListAndSearchFileRequestOptions
464467

465468
options = ListAndSearchFileRequestOptions(
466469
type='file',
467470
sort='ASC_CREATED',
468471
path='/',
469-
search_query="created_at >= '2d' OR size < '2mb' OR format='png'",
470472
file_type='all',
471473
limit=5,
472474
skip=0,
@@ -485,6 +487,29 @@ print(result.response_metadata.raw)
485487
print(result.list[0].file_id)
486488
```
487489

490+
#### Advance Search
491+
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`.
492+
493+
```Python
494+
from imagekitio.models.ListAndSearchFileRequestOptions import ListAndSearchFileRequestOptions
495+
496+
options = ListAndSearchFileRequestOptions(
497+
search_query="createdAt >= '2d' OR size < '2mb' OR format='png'",
498+
)
499+
500+
result = imagekit.list_files(options=options)
501+
502+
# Final Result
503+
print(result)
504+
505+
# Raw Response
506+
print(result.response_metadata.raw)
507+
508+
# print the first file's ID
509+
print(result.list[0].file_id)
510+
```
511+
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).
512+
488513
**2. Get File Details**
489514

490515
Accepts the file ID and fetches the details as per

0 commit comments

Comments
 (0)