Skip to content

Commit 191fdec

Browse files
ANKUR DWIVEDIANKUR DWIVEDI
authored andcommitted
update readme
1 parent 57ad078 commit 191fdec

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

README.md

Lines changed: 24 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,27 @@ 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`.
503+
504+
```java
505+
String[] tags = new String[3];
506+
tags[0] = "Software";
507+
tags[1] = "Developer";
508+
tags[2] = "Engineer";
509+
GetFileListRequest getFileListRequest = new GetFileListRequest();
510+
getFileListRequest.setSearchQuery("createdAt >= '2d' OR size < '2mb' OR format='png'");
511+
ResultList resultList = ImageKit.getInstance().getFileList(getFileListRequest);
512+
System.out.println("======FINAL RESULT=======");
513+
System.out.println(resultList);
514+
System.out.println("Raw Response:");
515+
System.out.println(resultList.getResponseMetaData().getRaw());
516+
System.out.println("Map Response:");
517+
System.out.println(resultList.getResponseMetaData().getMap());
518+
```
519+
520+
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).
521+
499522
**2. Get File Details**
500523

501524
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)