Skip to content

Commit 48e94f1

Browse files
authored
Merge pull request #33 from imagekit-developer/IK-1400
update readme
2 parents 57ad078 + 856bcc1 commit 48e94f1

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,9 @@ The SDK provides a simple interface for all the [media APIs mentioned here](http
473473

474474
Accepts an object of class `GetFileListRequest` specifying the parameters to be used to list and search files. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/list-and-search-files) can be passed via their setter functions to get the results.
475475

476+
#### Applying Filters
477+
Filter out the files by specifying the parameters.
478+
476479
```java
477480
String[] tags = new String[3];
478481
tags[0] = "Software";
@@ -482,7 +485,6 @@ GetFileListRequest getFileListRequest = new GetFileListRequest();
482485
getFileListRequest.setType("file");
483486
getFileListRequest.setSort("ASC_CREATED");
484487
getFileListRequest.setPath("/");
485-
getFileListRequest.setSearchQuery("createdAt >= '2d' OR size < '2mb' OR format='png'");
486488
getFileListRequest.setFileType("all");
487489
getFileListRequest.setLimit("4");
488490
getFileListRequest.setSkip("1");
@@ -496,6 +498,23 @@ System.out.println("Map Response:");
496498
System.out.println(resultList.getResponseMetaData().getMap());
497499
```
498500

501+
#### Advance Search
502+
In addition, you can fine-tune your query by specifying various filters by generating a query string in a Lucene-like syntax and setting this generated string to the `GetFileListRequest` object using `setSearchQuery` function.
503+
504+
```java
505+
GetFileListRequest getFileListRequest = new GetFileListRequest();
506+
getFileListRequest.setSearchQuery("createdAt >= '2d' OR size < '2mb' OR format='png'");
507+
ResultList resultList = ImageKit.getInstance().getFileList(getFileListRequest);
508+
System.out.println("======FINAL RESULT=======");
509+
System.out.println(resultList);
510+
System.out.println("Raw Response:");
511+
System.out.println(resultList.getResponseMetaData().getRaw());
512+
System.out.println("Map Response:");
513+
System.out.println(resultList.getResponseMetaData().getMap());
514+
```
515+
516+
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).
517+
499518
**2. Get File Details**
500519

501520
Accepts the file ID and fetches the details as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-details)

0 commit comments

Comments
 (0)