-
Notifications
You must be signed in to change notification settings - Fork 18
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
(dsl): Support create and upsert requests #6
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
25b7547
Provide initial getById Elasticsearch request
drmarjanovic b4f8cc9
Format code
drmarjanovic f6fdae8
Improve getById request
drmarjanovic 6df97b5
Code cleanup
drmarjanovic 61af183
Refactor ElasticRequest
dbulaja98 8374b3b
Add error message to JsonDecoderError
markaya 08a0775
Rename 'Index' to 'IndexName'
drmarjanovic 85ee8af
Extract elastic errors to a separated file
dbulaja98 adbfa88
Provide initial put Elasticsearch request
dbulaja98 e7720b2
Refactor put request
dbulaja98 23aa2b3
Move Document to separate file
dbulaja98 fa53a1d
Rename apply to from in Document
dbulaja98 ba20e40
Divide put to create and upsert
dbulaja98 85a902a
Refactor code
dbulaja98 12911f5
Add default routing for create with document id
dbulaja98 3387a17
Reorganize methods
dbulaja98 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
15 changes: 15 additions & 0 deletions
15
modules/library/src/main/scala/zio/elasticsearch/Document.scala
This file contains 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,15 @@ | ||
package zio.elasticsearch | ||
|
||
import zio.schema.Schema | ||
import zio.schema.codec.JsonCodec.JsonDecoder | ||
import zio.schema.codec.{DecodeError, JsonCodec} | ||
|
||
private[elasticsearch] final case class Document(json: String) { | ||
def decode[A](implicit schema: Schema[A]): Either[DecodeError, A] = JsonDecoder.decode(schema, json) | ||
} | ||
|
||
private[elasticsearch] object Document { | ||
def from[A](doc: A)(implicit schema: Schema[A]): Document = Document( | ||
JsonCodec.jsonEncoder(schema).encodeJson(doc, indent = None).toString | ||
) | ||
} |
This file contains 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 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
11 changes: 0 additions & 11 deletions
11
modules/library/src/main/scala/zio/elasticsearch/package.scala
This file was deleted.
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.
I would add both:
create(index: IndexName, id: DocumentId, doc: A...)
and
create(index: IndexName, doc: A)
.We are seeking to provide simpler public API and make our library usage easier, so it makes sense to provide rich public API.