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

Searching data types - map support [JIRA: CLIENTS-1029] #332

Open
mikrofusion opened this issue Nov 11, 2016 · 5 comments
Open

Searching data types - map support [JIRA: CLIENTS-1029] #332

mikrofusion opened this issue Nov 11, 2016 · 5 comments

Comments

@mikrofusion
Copy link

The docs talk to the ability to use search with CRDTs. Their are counters & sets examples which for multiple languages, which works great. Unfortunately the examples on searching maps don't include erlang:

http://docs.basho.com/riak/kv/2.1.4/developing/usage/searching-data-types/#maps-example

Does that mean this client only supports the counter & set data types? If map is supported (hopefully it is), is there somewhere with examples that can be referenced? I attempted to follow the same pattern as searching counters & sets, but was unsuccessful.

Thanks for your help.

@Basho-JIRA Basho-JIRA changed the title Searching data types - map support Searching data types - map support [JIRA: CLIENTS-1029] Nov 11, 2016
@lukebakken
Copy link
Contributor

Can you provide the following?

  • What Riak Search (Solr/Yokozuna) schema you are using? If you're using a custom schema, please provide the xml.
  • A sample object that is indexed.
  • The code you're using to search for the map object.

@lukebakken lukebakken added this to the riak-erlang-client-2.5.1 milestone Nov 11, 2016
@lukebakken lukebakken self-assigned this Nov 11, 2016
@mikrofusion
Copy link
Author

Hi @lukebakken - thanks for the response.

I am using the default Riak Search schema (_yz_default). I put it into a gist here: https://gist.github.com/mikrofusion/a084a7140f706243dbdd0a64f612990c

For some background, we are planning on using Riak + elixir for a large project at work. My spike on testing the riak-erlang-client + Riak + elixir is here: https://github.com/mikrofusion/elixir_riak

The spec that is failing is the following:

      context "searching maps" do
        before do
          :ok = :riakc_pb_socket.create_search_index(shared.pid, "map_search")
          :ok = :riakc_pb_socket.set_search_index(shared.pid, {"maps", "bucket"}, "map_search")

          map = :riakc_map.new()
          map = :riakc_map.update({"reg", :register},
            fn(r) -> :riakc_register.set("foo", r) end,
          map)

          :ok = :riakc_pb_socket.update_type(shared.pid, {"maps", "bucket"}, "key", :riakc_map.to_op(map))

          :timer.sleep(1000) # note: appears it takes some time to index
        end

        it "allows you to fetch the results" do
          # doesn't seem to work, looking for help here:
          # https://github.com/basho/riak-erlang-client/issues/332
          {:ok, {:search_results, results, _, _}} = :riakc_pb_socket.search(shared.pid, "map_search", "maps:*")

          expect Enum.count(results) |> to(eq 1)
        end
      end

Found here: https://github.com/mikrofusion/elixir_riak/blob/master/spec/test_spec.exs#L445

Similar specs above (with counters and sets) work fine.

Thanks again for all your help.

@lukebakken
Copy link
Contributor

I will try to get to this today or tomorrow as time allows.

@lukebakken lukebakken modified the milestones: riak-erlang-client-2.5.1, riak-erlang-client-2.5.2 Dec 6, 2016
@churcho
Copy link

churcho commented Feb 5, 2017

Any traction on this? I am facing the same issue with my implementation.

@churcho
Copy link

churcho commented Feb 6, 2017

I think I found a way to make my search work.

Had to carefully read this section In there it says

To query embedded fields, you must provide the name of the field.

An example is given like :Maps containing a set called hobbies hobbies_set:*

In my case I have a users bucket of type CRDT maps with a register field called username which I am using for my search indexing.

def search_by_index(index, field_name, search_param) do
   :riakc_pb_socket.search(:pooler.take_group_member(:riak), index, "#{field_name}:#{search_param}", [])
 end

I am calling seach_by_index this way:
search_by_index("email", "email_register","[email protected]")

That gives me the desired results.

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

No branches or pull requests

4 participants