Skip to content
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

working with Livebook #126

Open
ndrean opened this issue Sep 9, 2024 · 0 comments
Open

working with Livebook #126

ndrean opened this issue Sep 9, 2024 · 0 comments

Comments

@ndrean
Copy link

ndrean commented Sep 9, 2024

I tried without success to use snap from a Livebook. (also referenced in #94 ).

I installed finch (instead of Req) and run an OpenSearch image:

docker pull opensearchproject/opensearch:latest
docker pull opensearchproject/opensearch-dashboards:latest

docker run -d --name opensearch \
  -p 9200:9200  -p 9600:9600 \
  -e "discovery.type=single-node" \
  -e "OPENSEARCH_INITIAL_ADMIN_PASSWORD=a K 12 3 45 6 78 9?" \
  -e "cluster.name=my-cluster" \
  -e "node.name=node1" \
  -v open-search:/usr/share/opensearch/data \
  opensearchproject/opensearch:latest

The Livebook:

Mix.install([{:snap, "~> 0.11"}, {:finch, "~> 0.19"}])

defmodule MyApp.Cluster do
  use Snap.Cluster, opt_app: :noop
end

Finch.start_link(name: MyFinch)

{:ok, _} = Kino.start_child(
  {MyApp.Cluster, [
    url: "http://localhost:9200", 
    username: "admin",
    password: "a K 12 3 45 6 78 9#"
  ]
  }
)

I create an index and define a map with two fields "title" and "chunk_text" of type "text":

map = %{
  "mappings" => %{
    "properties" => %{
      "title" => %{"type" => "text"},
      "chunk_text" => %{
        "type" => "text",
        "fields" => %{
          "raw" => %{"type" => "keyword"}
        }
      }
    }
  }
}

Snap.Indexes.create(MyApp.Cluster, "my-index", map)

I get in the Livebook:

{:error, %Snap.HTTPClient.Error{reason: :closed, origin: %Mint.TransportError{reason: :closed}}}

and in the terminal (running livebook server)

[debug] Elasticsearch GET request path=/my-index/_doc status= response=12ms decode=0ms total=12ms

Besides the connection failure, the create index documentation indicates a PUT request whilst this generates GET request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant