Skip to content

Instantly share code, notes, and snippets.

@drewkerrigan
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drewkerrigan/17af260ca88071ecde92 to your computer and use it in GitHub Desktop.
Save drewkerrigan/17af260ca88071ecde92 to your computer and use it in GitHub Desktop.
Basho Bench Riak Search Examples
{mode, max}.
{duration, 1}.
{concurrent, 1}.
{driver, basho_bench_driver_http}.
{key_generator, {int_to_str, {uniform_int, 50000}}}.
{value_generator, {fixed_bin, 10000}}.
{generators, [
{age, {key_generator, {int_to_str, {uniform_int, 100}}}}
]}.
{values, []}.
{headers, [
{empty_h, []}
]}.
{targets, [
{simple, {"localhost", 8098, "/search/query/product_index?q=*:*"}},
{range_q, {"localhost", 8098, {"/search/query/my_index3?wt=json&q=age_i:[1%20TO%20~s]&rows=10", [age]}}}
]}.
{operations, [
{{get, simple}, 1},
{{get, range_q}, 1}
]}.
{mode, max}.
{duration, 1}.
{concurrent, 1}.
{driver, basho_bench_driver_riakc_pb}.
{riakc_pb_ips, [
{{127,0,0,1}, 8087}
]}.
{riakc_pb_search_queries, [{<<"product_index">>, "*:*", [{rows,10}]}]}. %% last element of the tuple is a list of Search options/params.
{operations, [{search, 1}]}.
{mode, max}.
{duration, 1}.
{concurrent, 1}.
{driver, basho_bench_driver_riakc_pb}.
{riakc_pb_ips, [
{{127,0,0,1}, 8087}
]}.
{riakc_pb_search_queries, [
{<<"index1">>, "*:*", []}, %% queries for everything using default # of returned records (100 or so?)
{<<"index2">>, "field1_s:wildcarded*", [{rows,10}]}, %% queries for field1 which starts with "wildcarded" with a limit of 10 returned records
{<<"index3">>, "age_i:[1%20TO%20100]", [{rows,1000}]}, %% queries for ages between 1 and 100 with a limit of 1000 returned records
]}.
{operations, [{search, 1}]}.
{mode, max}.
{duration, 1}.
{concurrent, 1}.
{driver, basho_bench_driver_http}.
%% Default generators, reference by the atoms key_generator and value_generator
{key_generator, {int_to_str, {partitioned_sequential_int, 50000}}}.
{value_generator, {fixed_bin, 10000}}.
%%% Generators: {Name, KeyGen | ValGen}
% Name: atom()
% KeyGen: User or Basho Bench defined key generator
% ValGen: User or Basho Bench defined value generator
{generators, [
{string_g, {key_generator, {int_to_str, {uniform_int, 50000}}}}
]}.
%%% Values: {Name, Value}
%%% {Name, {FormattedValue, Generators}}
% Name: atom()
% Value: string() | atom() - named generator, can be key_generator or value_generator for default
% FormattedValue: string() - formatted with io_lib:format
% Generators: list() - list of generators, can be key_generator or value_generator for default
{values, [
{json_v, {"{\"this\":\"is_json_~s\"}", [string_g]}}
]}.
%%% Headers: {Name, Headers}
% Name: atom()
% Headers: proplist()
{headers, [
{json_h, [{'Content-Type', 'application/json'}]}
]}.
%%% Targets: {Name, {Host, Port, Path}}
%%% {Name, [{Host1, Port1, Path1},{Host2, Port2, Path2},...]}
%%% {Name, {Host, Port, {FormattedPath, Generators}}}
%%% {Name, [{Host1, Port1, {FormattedPath1, Generators1}},{Host2, Port2, {FormattedPath2, Generators2}},...]}
% Name: atom()
% Host: string()
% Port: integer()
% Path: string()
% FormattedPath: string() - formatted with io_lib:format
% Generators: list() - list of generators, can be key_generator or value_generator for default
{targets, [
{base, {"localhost", 8098, {"/types/mytype/buckets/mybucket/keys/~s", [key_generator]}}}
]}.
%%% Operations: {{get|delete, Target}, Weight}
%%% {{get|delete, Target, Header}, Weight}
%%% {{put|post, Target, Value}, Weight}
%%% {{put|post, Target, Value, Header}, Weight}
% Target: atom() - defined target
% Header: atom() - defined header
% Value: atom() - defined value
% Weight: integer() - ratio of this operation to the rest (ThisWeight / TotalWeightSum = % of this Operation)
{operations, [
%% Put with a json object
{{put, base, json_v, json_h}, 1}
]}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment