Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(java): add overload for browseObjects #3351

Merged
merged 6 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,17 @@ jobs:
path: tests/output/javascript/node_modules
key: node-modules-tests-${{ hashFiles('tests/output/javascript/yarn.lock') }}

- name: Run CTS
id: cts
- name: Run unit CTS
run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} --exclude-e2e

- name: Run e2e CTS
id: cts-e2e
continue-on-error: true
run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} ${{ github.event.pull_request.head.repo.fork && '--exclude-e2e' || '' }}
if: ${{ !github.event.pull_request.head.repo.fork }}
run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} --exclude-unit

- name: Retry e2e CTS
if: ${{ !github.event.pull_request.head.repo.fork && github.event.number && steps.cts.outcome == 'failure' }}
if: ${{ !github.event.pull_request.head.repo.fork && steps.cts-e2e.outcome == 'failure' }}
run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} --exclude-unit

- name: Generate code snippets for documentation
Expand Down Expand Up @@ -331,13 +335,17 @@ jobs:
- name: Generate CTS
run: yarn cli cts generate ${{ matrix.client.language }} ${{ matrix.client.toRun }}

- name: Run CTS
id: cts
- name: Run unit CTS
run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} --exclude-e2e

- name: Run e2e CTS
id: cts-e2e
continue-on-error: true
run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} ${{ github.event.pull_request.head.repo.fork && '--exclude-e2e' || '' }}
if: ${{ !github.event.pull_request.head.repo.fork }}
run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} --exclude-unit

- name: Retry e2e CTS
if: ${{ !github.event.pull_request.head.repo.fork && steps.cts.outcome == 'failure' }}
if: ${{ !github.event.pull_request.head.repo.fork && steps.cts-e2e.outcome == 'failure' }}
run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} --exclude-unit

- name: Generate code snippets for documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void main(String[] args) throws Exception {

var options = new ClientOptions.Builder()
.addAlgoliaAgentSegment("Playground", "1.0.0")
.setLogLevel(LogLevel.BODY)
//.setLogLevel(LogLevel.BODY)
.build();

var client = new SearchClient(appId, apiKey, options);
Expand All @@ -44,6 +44,12 @@ public static void main(String[] args) throws Exception {
var response = client.batch(indexName, new BatchWriteParams().setRequests(batch));
client.waitForTask(indexName, response.getTaskID());

var browse = client.browseObjects(indexName, new BrowseParamsObject().setQuery("tom"), Actor.class);
System.out.println("-> Browse Objects:");
for (var hit : browse) {
System.out.println("> " + hit.name);
}

singleSearch(client, indexName, query);
multiSearch(indexName, query, client);
client.close();
Expand Down
10 changes: 10 additions & 0 deletions templates/java/api_helpers.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,16 @@ public <T> Iterable<T> browseObjects(String indexName, BrowseParamsObject params
return browseObjects(indexName, params, innerType, null);
}

/**
* Helper: Returns an iterator on top of the `browse` method.
*
* @param indexName The index in which to perform the request.
* @param innerType The class held by the index, could be your custom class or {@link Object}.
*/
public <T> Iterable<T> browseObjects(String indexName, Class<T> innerType) {
return browseObjects(indexName, new BrowseParamsObject(), innerType, null);
}

/**
* Helper: Returns an iterator on top of the `searchSynonyms` method.
*
Expand Down
Loading