radar / elastic

A thin veneer over HTTPotion that talks to Elastic Search

Home Page:https://hex.pm/packages/elastic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

no function clause matching in Elastic.ResponseHandler.process

miskolc opened this issue · comments

commented

When I do indexing like this:

ProductDocument.index(product.id, data)

every now and then, I get this error:

** (FunctionClauseError) no function clause matching in Elastic.ResponseHandler.process/1
    (elastic) lib/elastic/response_handler.ex:4: Elastic.ResponseHandler.process(%HTTPotion.ErrorResponse{message: "req_timedout"})
    (elixir) lib/enum.ex:651: Enum."-each/2-lists^foreach/1-0-"/2
    (elixir) lib/enum.ex:651: Enum.each/2
    (elixir) lib/code.ex:363: Code.require_file/2
    (mix) lib/mix/tasks/run.ex:71: Mix.Tasks.Run.run/1
    (mix) lib/mix/task.ex:296: Mix.Task.run_task/3
    (mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2
    (elixir) lib/code.ex:363: Code.require_file/2

The indexing works( ie the document is indexed and can be search) but the script that does multiple indexing operations breaks after the first operation.

It seems that assigning the result to a variable
response = ProductDocument.index(product.id, data)
doesn't break the script after the first indexing operation but I'm not sure if this was the intended behaviour of the package.

What would be a better solution( if any)?

Hey Dragos,

Do you have a script that reproduces this problem that I could try to run?

On 23 Nov. 2016, at 12:36, Dragos notifications@github.com wrote:

When I do indexing like this:

ProductDocument.index(product.id, data)

every now and then, I get this error:

** (FunctionClauseError) no function clause matching in Elastic.ResponseHandler.process/1
(elastic) lib/elastic/response_handler.ex:4: Elastic.ResponseHandler.process(%HTTPotion.ErrorResponse{message: "req_timedout"})
(elixir) lib/enum.ex:651: Enum."-each/2-lists^foreach/1-0-"/2
(elixir) lib/enum.ex:651: Enum.each/2
(elixir) lib/code.ex:363: Code.require_file/2
(mix) lib/mix/tasks/run.ex:71: Mix.Tasks.Run.run/1
(mix) lib/mix/task.ex:296: Mix.Task.run_task/3
(mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2
(elixir) lib/code.ex:363: Code.require_file/2
The indexing works( ie the document is indexed and can be search) but the script that does multiple indexing operations breaks after the first operation.

It seems that assigning the result to a variable
response = ProductDocument.index(product.id, data)
doesn't break the script after the first indexing operation but I'm not sure if this was the intended behaviour of the package.

What would be a better solution( if any)?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

commented

I don't have a script because I ran that line of code in the console, but I've noticed the error happens when I run that instruction shortly after I open iex.

Also since I've initially opened this issue, I've noticed that this error also appears when I do a bulk create with too many rows( ie Elastic.Bulk.create(indexable_chunk)). If index_chunk has more that 10_000 tuples in it, I get that error, otherwise, if it's 10_000 or less I get no error and I also don't need to assign the result to any variable.

So now I think the error has more to do with the fact that ES can't handle new requests at a certain point in time, rather that what I said in my previous comment.

Ok, no worries. I don't know of a good way to make Elastic.Bulk.create complain if you pass it a large amount of chunks... or even if it should complain!

I think the req_timedout message should be handled better, and so I've made 39c9bc7 for that.