How do I index already existing objects in Riak - riak

I created a bucket in riak and stored some key value pairs (value being a json object). After this I ran /usr/sbin/search-cmd install <bucket> to start riak search for the bucket.
Each object has a 'type' attribute and I am trying to search objects of particular type using /usr/sbin/search-cmd search <bucket> "type:xyz" but I get the following error:
RPC to 'riak#127.0.0.1' failed: {'EXIT',
{badarg,
[{ets,lookup,
[schema_table,<<"catalog">>],
[]},
{riak_search_config,get_schema,1,
[{file,"src/riak_search_config.erl"},
{line,69}]},
{riak_search_client,parse_query,3,
[{file,"src/riak_search_client.erl"},
{line,57}]},
{search,search,3,
[{file,"src/search.erl"},{line,55}]},
{riak_search_cmd,search,3,
[{file,"src/riak_search_cmd.erl"},
{line,188}]},
{rpc,'-handle_call_call/6-fun-0-',5,
[{file,"rpc.erl"},{line,203}]}]}}
I read that indexing happens through a pre-commit hook so I also POSTed all objects again but still no results. Am I missing any step in setting up riak search?

Figured that riak search was not enabled in my app.config.

Related

List available collections for database in ArangoDB using HTTP interface?

I am trying to use ArangoDB's HTTP interface to dump all collections belonging to a specific database.
I am able to view all available databases using the following command:
curl http://localhost:8529/_api/database
However, once I find a database name (for example, "test") I am unable to dump the collections belonging to this database. Ultimately, I would like to dump the collections for this database, and then all results within a chosen collection.
I have followed the documentation provided here: https://www.arangodb.com/docs/stable/http/general.html, however I am still unable to find the relevant documentation for this request.
You can get the list of all collections with
curl http://localhost:8529/_db/DBNAME/_api/collection
as is implied in this part of the documentation: https://www.arangodb.com/docs/stable/http/collection.html#address-of-a-collection
The rest of the interface works accordingly, e.g.
curl http://localhost:8529/_db/DBNAME/_api/collection/COLLNAME
to get information about a single collection (that is already included in the output of the first call).
You find the complete swagger documentation with just two clicks in the Web-Interface:

Getting this error org.mule.runtime.api.store.ObjectAlreadyExistsException: Object already exists for the key

I am getting this error on cloudhub "org.mule.runtime.api.store.ObjectAlreadyExistsException: Object already exists for the key".
I am using object store in my application. Where I am checking if the value is available in object store and then store it only if it is not available. I have set the option to "Fail if present" as false, still seeing this error.
How to resolve this?
I observed that this issue is coming only when I am using two workers in cloudhub.
Thanks in advance.
Edited:
Using Object Store connector and mule 4.3.
I am checking in object store using Contains if value exists. If it does then Retrieving the value else Storing it to OS.
Error
Edit2:
ObjectStore in Cloudhub:
The error message indicates that the application is using the default persistent object store. For sharing to multiple workers you should instead use the _defaultUserObjectStore which is in memory. Details are in: https://docs.mulesoft.com/object-store/osv2-faq#how-are-object-store-entries-divided-among-workers
You can try this approach!
Use a retrieve connector and wrap it in Try block. And define it own error handling strategy, in which use store connector in On Error Continue block. What it will do is, first it will try to retrieve the values stored in Object Store. If the keys will be present, respective values will be fetched. If the key is not present, an error will occur which will be handled by the error handler and will store the key to object store.

Determine if Cosmos DB NotFound due to missing collection vs. document

Is there a way to programmatically determine from a DocumentClientException where StatusCode == HttpStatusCode.NotFound whether it was the document, the collection, or the database that was not found?
I'm trying to figure out whether I can implement on-demand collection provisioning and only call DocumentClient.CreateDocumentCollectionIfNotExistsAsync when I need to. I'm trying to avoid calling it before making every request (presumably this adds an extra network roundtrip to every request). Likewise, I'm trying to avoid calling it on error recovery when I know it won't help.
From experimentation with the local emulator, the only field I see varying in these three cases is DocumentClientException.Error.Message, and only when the database cannot be found. I generally try to avoid exception dispatching based on human-readable messages.
Wrong database name:
StatusCode: HttpStatusCode.NotFound
Error.Message: {\"Errors\":[\"Owner resource does not exist\"]}...
Correct database name, wrong collection name:
StatusCode: HttpStatusCode.NotFound
Error.Message: {\"Errors\":[\"Resource Not Found\"]}...
Correct database name, correct collection name, incorrect document ID:
StatusCode: HttpStatusCode.NotFound
Error.Message: {\"Errors\":[\"Resource Not Found\"]}...
I'm planning to use a database with its own offer. Since collections inside a database with its own offer are cheap, I'm trying to see whether I can segregate each tenant in my multi-tenant application into its own collection. Each tenant ends up having a different indexing and default TTL policy. The set of collections is not fixed and changes dynamically during runtime as new tenants sign up. I cannot predict when I will need to add a new collection. There's no new tenant notification: I just get a request that I need to handle by creating a document in a possibly non-existent collection. There's a process to garbage collect unused collections.
I'm using the NuGet package Microsoft.Azure.DocumentDB.Core Version 1.9.1 in a .NET Core 2.1 app targeting a SQL API Cosmos DB instance.
If you look at the Message property in detail, you should see following strings that informs whether 404 Not Found response was generated due to Document vs Collection.
ResourceType: Document
ResourceType: Collection
It's not ideal but you can try to regex this information out of error message.

Querying Titan ElasticSearch backend via Rexster

I have Titan 0.3.2 running in embedded mode, and have been able to create and query ElasticSearch indexes via the Gremlin shell (see previous question). I am using the default configuration, which calls the ES index "search".
These searches return the correct nodes without error via the Gremlin shell:
g.query().has('my_label','abc').vertices()
g.query().has('my_label',CONTAINS,'abc').vertices()
However, if I attempt to run these same Gremlin queries via RexPro, Rexster sends back this error for the first query above:
java.util.concurrent.ExecutionException:
javax.script.ScriptException:
javax.script.ScriptException:
java.lang.IllegalArgumentException: Index is unknown or not configured: search
and this for the second:
java.util.concurrent.ExecutionException:
javax.script.ScriptException:
javax.script.ScriptException:
groovy.lang.MissingPropertyException: No such property: CONTAINS for class: Script3
Similarly, if I try to query on the indexed key via the REST API (GET):
http://localhost:8182/graphs/graph/vertices?key=my_key&value=abc
I receive the same error response:
{"message":"Index is unknown or not configured: search","error":"Index is unknown or not configured: search"}
Lastly, if I try to start with a clean database and run the index creation script through rexpro:
g.makeType().name("my_label").dataType(String.class).indexed("search", Vertex.class).unique(Direction.OUT).makePropertyKey();
I see the same unknown index error:
java.util.concurrent.ExecutionException:
javax.script.ScriptException:
javax.script.ScriptException:
java.lang.IllegalArgumentException: Index is unknown or not configured: search
So it seems that Rexster needs some additional information about the indexing backend, possibly in its configuration file (I am using the default one included with the installation). Anyone familiar with this issue? Happy to provide more information.
You might have a mix of things going on, but the main thing is that as of Titan 0.3.2, Rexster does not automatically import Titan classes, so you can't query with CONTAINS. You need to specify the full package name when doing so:
com.thinkaurelius.titan.core.attribute.Text.CONTAINS
I can't say for sure what else is wrong, but it looks like the elastic search index is not configured properly. That doesn't have much to do with the Rexster configuration file for Titan Server. It has more to do with the second argument you pass to titan.sh which contains Titan configuration information. Make sure that elastic search is properly configured as it is in this file shown here (default with the installation): https://github.com/thinkaurelius/titan/blob/master/config/titan-server-cassandra-es.properties

Riak Map/Reduce enableForSearch() error

I'm trying to use the Riak Java Client in an application, however I'm facing some errors. What I need is to perform a Riak Search query as input for a Map/Reduce. According to the official tutorial the search property must be enabled in the Bucket. I'm doing so, in the following code:
IRiakClient riakClient = RiakFactory.httpClient(HTTP_CLIENT);
Bucket bucket = (Bucket) riakClient.createBucket("test-bucket").enableForSearch().execute();
When I do this, the store operation, in the Bucket, doesn't work anymore. And the following error appears:
com.basho.riak.client.RiakRetryFailedException: java.io.IOException: 500 Error:
{precommit_fail,{hook_crashed,{riak_search_kv_hook,precommit,error,badarg}}}
I've already googled the problem, but it wasn't much help!
Do you have search enabled in your app.config? Find this section
%% Riak Search Config
{riak_search, [
%% To enable Search functionality set this 'true'.
{enabled, false}
]},
and set enabled to true.

Resources