Skip to content

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

@mikrofusion

Description

@mikrofusion

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.

Activity

changed the title [-]Searching data types - map support[/-] [+]Searching data types - map support [JIRA: CLIENTS-1029][/+] on Nov 11, 2016
lukebakken

lukebakken commented on Nov 11, 2016

@lukebakken
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.
self-assigned this
on Nov 11, 2016
mikrofusion

mikrofusion commented on Nov 11, 2016

@mikrofusion
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

lukebakken commented on Nov 14, 2016

@lukebakken
Contributor

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

modified the milestones: riak-erlang-client-2.5.1, riak-erlang-client-2.5.2 on Dec 6, 2016
churcho

churcho commented on Feb 5, 2017

@churcho

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

churcho

churcho commented on Feb 6, 2017

@churcho

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","myemail@test.com")

That gives me the desired results.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @churcho@lukebakken@mikrofusion@Basho-JIRA

        Issue actions

          Searching data types - map support [JIRA: CLIENTS-1029] · Issue #332 · basho/riak-erlang-client