Skip to content

Commit

Permalink
Add search flag into base clients (#448)
Browse files Browse the repository at this point in the history
Co-authored-by: Jesse Jia <[email protected]>
  • Loading branch information
zhixuanjia and Jesse Jia authored Oct 11, 2024
1 parent c6be657 commit ecfff54
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ public BaseBrowsableClient(@Nonnull Client restliClient) {
public abstract BrowseResult browse(@Nonnull String inputPath, @Nullable Map<String, String> requestFilters, int from, int size)
throws RemoteInvocationException;

/**
* Browse method that allows caller to choose the platform.
*/
@Nonnull
public BrowseResult browse(@Nonnull String inputPath, @Nullable Map<String, String> requestFilters, @Nullable SearchPlatform searchPlatform,
int from, int size) throws RemoteInvocationException {
throw new UnsupportedOperationException("Not implemented yet.");
}

/**
* Returns a list of paths for a given urn.
*
Expand All @@ -49,4 +58,11 @@ public StringArray getBrowsePaths(@Nonnull URN urn) throws RemoteInvocationExcep
throw new UnsupportedOperationException("Not implemented yet.");
}

/**
* Returns a list of paths for a given urn and allows caller to choose the platform.
*/
@Nonnull
public StringArray getBrowsePaths(@Nonnull URN urn, @Nullable SearchPlatform searchPlatform) throws RemoteInvocationException {
throw new UnsupportedOperationException("Not implemented yet.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@
*/
public abstract class BaseSearchableClient<VALUE extends RecordTemplate> extends BaseClient {

public enum SearchPlatform {
ELASTICSEARCH("elasticsearch"),
HOSTEDSEARCH("hostedsearch");

private final String platformName;

SearchPlatform(String platform) {
this.platformName = platform;
}

public String getPlatformName() {
return platformName;
}
}

public BaseSearchableClient(@Nonnull Client restliClient) {
super(restliClient);
}
Expand All @@ -41,6 +56,16 @@ public abstract CollectionResponse<VALUE> search(@Nonnull String input, @Nullabl
@Nullable Map<String, String> requestFilters, @Nullable SortCriterion sortCriterion, int start, int count)
throws RemoteInvocationException;

/**
* Similar to {@link #search(String, StringArray, Map, SortCriterion, int, int)} with platform flag to indicate the request
* should be served by elasticsearch or hostedsearch.
*/
public CollectionResponse<VALUE> search(@Nonnull String input, @Nullable StringArray aspectNames,
@Nullable Map<String, String> requestFilters, @Nullable SortCriterion sortCriterion, @Nullable SearchPlatform platform,
int start, int count) throws RemoteInvocationException {
throw new UnsupportedOperationException("Not implemented in BaseSearchableClient.");
}

/**
* Similar to {@link #search(String, StringArray, Map, SortCriterion, int, int)} with null for aspect names, meaning
* all aspects will be returned.
Expand All @@ -51,6 +76,15 @@ public CollectionResponse<VALUE> search(@Nonnull String input, @Nullable Map<Str
return search(input, null, requestFilters, sortCriterion, start, count);
}

/**
* Autocomplete with search platform flag.
*/
@Nonnull
public AutoCompleteResult autocomplete(@Nonnull String query, @Nullable String field, @Nullable Map<String, String> requestFilters,
@Nullable SearchPlatform platform, int limit) throws RemoteInvocationException {
throw new UnsupportedOperationException("Not implemented in BaseSearchableClient.");
}

/**
* Autocomplete method that the client will override only if they need this capability.
*
Expand Down

0 comments on commit ecfff54

Please sign in to comment.