Skip to content

Commit

Permalink
feat(java): browse objects/synonyms/rules (#952)
Browse files Browse the repository at this point in the history
  • Loading branch information
millotp authored Aug 25, 2022
1 parent af29144 commit 68ff7ee
Show file tree
Hide file tree
Showing 7 changed files with 421 additions and 248 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.algolia.utils;

import java.util.Iterator;
import java.util.function.BooleanSupplier;
import java.util.function.Supplier;

public class AlgoliaIterableHelper {

public static <T> Iterable<T> createIterable(Supplier<Iterator<T>> executeQuery, BooleanSupplier _hasNext) {
return new Iterable<T>() {
@Override
public Iterator<T> iterator() {
return new Iterator<T>() {
private boolean isFirstRequest = true;
private Iterator<T> currentIterator = null;

@Override
public boolean hasNext() {
if (isFirstRequest || (_hasNext.getAsBoolean() && !currentIterator.hasNext())) {
currentIterator = executeQuery.get();
isFirstRequest = false;
}
return currentIterator != null && currentIterator.hasNext();
}

@Override
public T next() {
if (currentIterator == null || !currentIterator.hasNext()) {
currentIterator = executeQuery.get();
isFirstRequest = false;
}
return currentIterator.next();
}
};
}
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.algolia.utils;

public class Holder<T> {

public T value;

public Holder() {
this.value = null;
}

public Holder(T value) {
this.value = value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public static void main(String[] args) {
SearchResponses<Actor> sr = result.get();
Actor a = sr.getResults().get(0).getHits().get(0);
System.out.println(a.name);

} catch (InterruptedException e) {
System.err.println("InterrupedException" + e.getMessage());
e.printStackTrace();
Expand Down
11 changes: 0 additions & 11 deletions specs/search/paths/synonyms/common/schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,6 @@ synonymHit:
items:
type: string
description: List of query words that will match the token.
_highlightResult:
type: object
description: Highlighted results.
additionalProperties: false
properties:
type:
$ref: '../../../common/schemas/Hit.yml#/highlightResultMap'
synonyms:
type: array
items:
$ref: '../../../common/schemas/Hit.yml#/highlightResultMap'
required:
- objectID
- type
Expand Down
4 changes: 2 additions & 2 deletions specs/search/paths/synonyms/searchSynonyms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ post:
description: Search or browse all synonyms, optionally filtering them by type.
parameters:
- $ref: '../../../common/parameters.yml#/IndexName'
- $ref: 'common/parameters.yml#/Type'
- $ref: './common/parameters.yml#/Type'
- $ref: '../../../common/parameters.yml#/PageDefault0'
- $ref: '../../../common/parameters.yml#/HitsPerPage'
requestBody:
Expand All @@ -28,7 +28,7 @@ post:
content:
application/json:
schema:
$ref: 'common/schemas.yml#/searchSynonymsResponse'
$ref: './common/schemas.yml#/searchSynonymsResponse'
'400':
$ref: '../../../common/responses/BadRequest.yml'
'402':
Expand Down
244 changes: 9 additions & 235 deletions templates/java/api.mustache

Large diffs are not rendered by default.

Loading

0 comments on commit 68ff7ee

Please sign in to comment.