Skip to content

Instantly share code, notes, and snippets.

@dankerrigan
Last active January 3, 2016 12:59
Show Gist options
  • Save dankerrigan/8466447 to your computer and use it in GitHub Desktop.
Save dankerrigan/8466447 to your computer and use it in GitHub Desktop.
Getting started with Riak 2.0 Search
# Create an index
curl -XPUT -i 'http://localhost:8098/search/index/user_index'
# Create and activate a Riak bucket-type
riak-admin bucket-type create data '{"props":{}}'
riak-admin bucket-type activate data
# Associate the index with the bucket, users
curl -i -H 'content-type: application/json' -X PUT 'http://localhost:8098/types/data/buckets/users/props' -d '{"props":{"search_index":"user_index"}}'
# Put an object into the users bucket, take note of the _s and _i suffix on field names which controls who they'll be dynamically indexed
curl -i -XPUT -H 'content-type: application/json' -d '{"first_name_s":"Dan","last_name_s":"Kerrigan","email_s":"dankerrigan@basho.com","activation_code_s":"12345"}' http://localhost:8098/types/data/buckets/users/keys/dan_0
# Exact match
curl -i 'http://localhost:8098/search/user_index?q=first_name_s:Dan&wt=json'
# Wildcard with a *
curl -i 'http://localhost:8098/search/user_index?q=first_name_s:D*&wt=json'
# Wildcard with a ?
curl -i 'http://localhost:8098/search/user_index?q=first_name_s:D?n&wt=json'
# See https://github.com/basho/yokozuna/blob/develop/docs/RESOURCES.md for mroe information
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment