Tyler-pierce / giza_sphinxsearch

Sphinx Fulltext Search Client for Elixir Projects (Phoenix Example Included)
19 stars 5 forks source link

`get_doc_ids/2` no match of right hand side error #7

Open riesha opened 6 months ago

riesha commented 6 months ago

Hi, this is my first time using this library and sphinx so i do not know if this is an issue with my usage/configuration or due to a sphinx update or something.

When trying to call get_doc_ids with the result of a sphinxql response, this match fails

Response:

{:ok,
 %Giza.Structs.SphinxqlResponse{
   fields: ["id"],
   total: 4,
   matches: [[243], [1230], [1452], [3032]]
 }}
  defp get_doc_ids([query_attr|tail], accum) do
    {doc_id, _} = query_attr # fail!!
    new_accum = [doc_id|accum]

    get_doc_ids(tail, new_accum)
  end

I've changed the code to this to make it work

defp get_doc_ids([query_attr|tail], accum) do
    doc_id = query_attr
    new_accum = [doc_id|accum]

    get_doc_ids(tail, new_accum)
  end

Now the question i have is this: Did sphinx change something with the returned matches field (using sphinx 3.0.2) which would cause this error now, or are my results just different due to a misconfiguration which would make this code edit breaking on other installs?

I'm new to elixir but if the original code's intention was to get the id from the list why not just do doc_id = hd(query_attr) which would return what the documentation shows ([1, 4, 6, 12, ..])