-
Notifications
You must be signed in to change notification settings - Fork 21
feat(java): browse objects/synonyms/rules #952
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...ient-java-2/algoliasearch-core/src/main/java/com/algolia/utils/AlgoliaIterableHelper.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
}; | ||
} | ||
}; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...lgoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/utils/Holder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't it still be there but a string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid in some case it can be the object, as defined here and in that case it would be a mess.
I'm not sure what's best
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe worth to go with what we know for now and assume that it can be an enum "synonym" or a free form object?
It should be enough until we have a proper use case to investigate, wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it still be valid once the Java unknown parameter validation is removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FAIL_ON_UNKNOWN_PROPERTIES
is already disabled for the client, but it will still fail when trying to deserialize a known property, maybe I could return null instead of throwing but then it's misleading.Are you sure this property is ever used for synonym ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for rules we have the same issue, it's listed in the doc but not in our spec
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the JS client,
browseRules
andbrowseSynonyms
both delete the_highlightResult
key for each responses, but not in thesearchRules
andsearchSynonyms
methods. I'd be fine keeping the same logic until we have some contextmaybe
@Haroenv(off) @francoischalifour (?) knows more about those?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, but I would guess that we prefer having consistent keys when using search endpoints to facilitate the data flow in the consumers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from usage it seems like
_highlightResult
is pretty random (example) so we remove it for now