Skip to content
Closed
Changes from all 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
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,25 @@ behaviour.
defmodule MyApp.ElasticsearchStore do
@behaviour Elasticsearch.Store

@impl Elasticsearch.Store
def load(MyApp.Post, offset, limit) do
def load(MyApp.Post, offset, limit) when offset <= 1_000 do
# Return MyApp.Posts, restricted by offset and limit
# a sample implementation to get you started:

[%MyApp.Post{title: "Name", author: "Author"}]
|> Stream.cycle()
|> Stream.map(&Map.put(&1, :id, random_str()))
|> Enum.take(5_000)
end

def load(_module, _offset, _limit) do
[]
end

defp random_str do
:crypto.strong_rand_bytes(32) |> Base.encode64()
end
end

```

#### Elasticsearch.Document
Expand Down