Skip to content

Commit 68ff7ee

Browse files
authored
feat(java): browse objects/synonyms/rules (#952)
1 parent af29144 commit 68ff7ee

File tree

7 files changed

+421
-248
lines changed

7 files changed

+421
-248
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.algolia.utils;
2+
3+
import java.util.Iterator;
4+
import java.util.function.BooleanSupplier;
5+
import java.util.function.Supplier;
6+
7+
public class AlgoliaIterableHelper {
8+
9+
public static <T> Iterable<T> createIterable(Supplier<Iterator<T>> executeQuery, BooleanSupplier _hasNext) {
10+
return new Iterable<T>() {
11+
@Override
12+
public Iterator<T> iterator() {
13+
return new Iterator<T>() {
14+
private boolean isFirstRequest = true;
15+
private Iterator<T> currentIterator = null;
16+
17+
@Override
18+
public boolean hasNext() {
19+
if (isFirstRequest || (_hasNext.getAsBoolean() && !currentIterator.hasNext())) {
20+
currentIterator = executeQuery.get();
21+
isFirstRequest = false;
22+
}
23+
return currentIterator != null && currentIterator.hasNext();
24+
}
25+
26+
@Override
27+
public T next() {
28+
if (currentIterator == null || !currentIterator.hasNext()) {
29+
currentIterator = executeQuery.get();
30+
isFirstRequest = false;
31+
}
32+
return currentIterator.next();
33+
}
34+
};
35+
}
36+
};
37+
}
38+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.algolia.utils;
2+
3+
public class Holder<T> {
4+
5+
public T value;
6+
7+
public Holder() {
8+
this.value = null;
9+
}
10+
11+
public Holder(T value) {
12+
this.value = value;
13+
}
14+
}

playground/java/src/main/java/com/algolia/playground/Search.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public static void main(String[] args) {
6464
SearchResponses<Actor> sr = result.get();
6565
Actor a = sr.getResults().get(0).getHits().get(0);
6666
System.out.println(a.name);
67+
6768
} catch (InterruptedException e) {
6869
System.err.println("InterrupedException" + e.getMessage());
6970
e.printStackTrace();

specs/search/paths/synonyms/common/schemas.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,6 @@ synonymHit:
3939
items:
4040
type: string
4141
description: List of query words that will match the token.
42-
_highlightResult:
43-
type: object
44-
description: Highlighted results.
45-
additionalProperties: false
46-
properties:
47-
type:
48-
$ref: '../../../common/schemas/Hit.yml#/highlightResultMap'
49-
synonyms:
50-
type: array
51-
items:
52-
$ref: '../../../common/schemas/Hit.yml#/highlightResultMap'
5342
required:
5443
- objectID
5544
- type

specs/search/paths/synonyms/searchSynonyms.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ post:
88
description: Search or browse all synonyms, optionally filtering them by type.
99
parameters:
1010
- $ref: '../../../common/parameters.yml#/IndexName'
11-
- $ref: 'common/parameters.yml#/Type'
11+
- $ref: './common/parameters.yml#/Type'
1212
- $ref: '../../../common/parameters.yml#/PageDefault0'
1313
- $ref: '../../../common/parameters.yml#/HitsPerPage'
1414
requestBody:
@@ -28,7 +28,7 @@ post:
2828
content:
2929
application/json:
3030
schema:
31-
$ref: 'common/schemas.yml#/searchSynonymsResponse'
31+
$ref: './common/schemas.yml#/searchSynonymsResponse'
3232
'400':
3333
$ref: '../../../common/responses/BadRequest.yml'
3434
'402':

templates/java/api.mustache

Lines changed: 9 additions & 235 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)