using cloudant nano to return documents matching a selector - cloudant

The selector is an object that describes the where part of the query. I've tried the db.list function but it' not honoring the selector.
The database admin tool of cloudant has a Query feature, you type in a selector, fields, and sort and away it goes. My guess is it's using the _find as opposed to _all_docs. (true?)
I don't see _find in the nano code. It be easy enough to call it directly, in which case I'd like to get access to the relax to do the http call.
1) should the selector work on db.list?
2) I'm using typescript, how can I get set up to use the relax method for the http?

Consider using the Cloudant library instead of Nano -- Cloudant's node library is a thin wrapper around Nano, giving you access to Cloudant-specific stuff. See https://github.com/cloudant/nodejs-cloudant

Related

Any examples of using a Wandsearcher in vespa ? (After a weighted set query)

Currently i am using the REST interface to query vespa, which seems to work great but something tells me that i should be using searchers in the application to make the client(server side code) a bit lighter (bundle the jar file in the application package) to make it a bit smoother. I have managed to do some simple searcher/processor applications. But this is a bit overwhelming.
So are there any readily available examples ?
Basicially i want to:
Send to /search?query=someId
Do a ordinary search for the weighted set on this documentID (I guess this one can be handy: https://docs.vespa.ai/documentation/reference/inspecting-structured-data.html)
Take those items in the response and add it to a wand item(s) and query for a wand with wandsearcher on a given field. Similar to the yql:
"select * from sources * where wand(interest, some weightedsets));","ranking":"combined_score" and return the matches.
Just curious also, apart from the trouble of string building with the http request i am doing at the moment are there any performance gains of using a searcher or go the java route vs rest?
thanks for any insight or code help i can start with.
There is an example of using the WandItem (YQL wand)here https://docs.vespa.ai/documentation/advanced-ranking.html and see also https://docs.vespa.ai/documentation/using-wand-with-vespa.html as there are two wand implementations available in Vespa, it sounds from the description that the wand() is what you want to use for this use case. For the first call you probably want to have a dedicated document summary to reduce the amount of data fetched for your first query and also the option of serving it out of memory only (See https://docs.vespa.ai/documentation/document-summaries.html)
Also see https://docs.vespa.ai/documentation/searcher-development.html as a general resource on writing searchers.
For your use case it makes a lot of sense to write a searcher to perform these two queries as your second query depends on the first and you avoid the cost of rendering/http/yql parsing which might matter if your client is remote with high network latency.

Why RexsterGraph is not meant for high-performing graph traversals?

Why RexsterGraph in the blueprint stack is not meant for high-performing graph traversals:
https://github.com/tinkerpop/blueprints/wiki/Rexster-Implementation
What are the limitations?
And should I then fallback on executing gremlin throw a simple string evaluated?
RexsterGraph uses the Rexster REST API which is a RESTful representation of the Blueprints API. As such, each Blueprints method called in RexsterGraph translates to an HTTP call.
Here's an example of why that's bad for "high performance traversals". Using the toy graph, for an example. Let's say I want to do something simple with RexsterGraph like: g.v(1).out.filter{it.name=='josh'}.name. That will translate to the following HTTP calls:
vertices/1 - gets data for v(1)
vertices/1/outE - gets the out edges for v(1)
vertices/2 - knowing the out edges tells us the other vertex to retrieve
vertices/3 - knowing the out edges tells us the other vertex to retrieve
vertices/4 - knowing the out edges tells us the other vertex to retrieve
vertices/2 - now we are filtering so we need the name property
vertices/3 - now we are filtering so we need the name property
vertices/4 - now we are filtering so we need the name property
vertices/4 - now we are down to "josh" so get the name property
As you can see, it's not efficient. It is a one-to-one mapping of the Blueprints API to the Rexster REST API. That's it. Could it be made to be more efficient? Probably...we might consider caching property values or something, but it will still be really chatty for a "high performance traversal". Other problems with trying to make it more efficient are dealing with mechanisms for serializing closures so that can be executed on the server.
In the end, it was simply decided a long time ago that this was not a good approach and we started to recommend against using RexsterGraph in favor of server-side DSLs and RexPro/REST Gremlin Extension.

ComboBox and dojo.store via ajax

I have a ComboBox and I'd like to fetch data from server first when user type at least 3 characters.
I've used dojo.data.* but it's deprecated and I cannot find something similar in dojo.store.* and xhr|ajax in one sentence. Do you have some tips?
I use declarative markup.
You probably used the dojox/data/QueryReadStore? There is no similar store at the moment I think. The best alternative you have (with the dojo/store API) is the JsonRest store.
But it isn't exactly the same, so you might have to extend it. You should probably start by looking at both API's (the old and the new API) and compare the dojox/data/QueryReadStore and the dojo/store/JsonRest to successfully extend it.

How to make another search call inside SOLR

I would like to implement some kind of fallback querying mechanism inside SOLR. That is if a first search call doesn't generate enough results, I would like to make another call with different ranking and then combine the results and return it. I guess this can be done in the SOLR client side but I hope to do this inside the SOLR. By reading documentation, I guess I need to implement a search component and then add it next to "query" component? Any reference or experience in this regard would be highly appreciated.
SearchHandler calls all the registered search components in order you define, and there are several stages (prepare,process etc.).
You know the number of results only after the distributed processing phase (I suppose you work with distributed mode),so your custom search component should check the number of results in response object and run its own query if necessary.
Actually you may inherit (or wrap) a regular QueryComponent for that, augmenting its process/distributed process phases.

XPathNavigator in Silverlight

I have a code library that makes heavy use of XPathNavigator to parse some specific xml document. The xml document is cross-referenced, meaning that an element can reference another which has not yet been encountered during parsing:
<ElementA ...>
<DependentElementX id="1234">
</ElementA>
<ElementX id="1234" .../>
The document doesn't really look like this, but the point is that 1) there is an xml schema that enforces the overall document structure, 2) elements inside the document can reference each other using some IDs, and 3) there is quite a few such cross references between different elements in the document.
The document is parsed in two phases. In the first pass I walk through the document
XPathDocument doc = ...;
XPathNavigator nav = doc.CreateNavigator();
nav.MoveToRoot();
nav.MoveToFirstChild()...
and occasionally 'bookmark' the current position (element) in the document using XPathNavigator.Clone() method. This gives me a lightweight instance of an XPathNavigator which I can store somewhere and use later to jump back to a particular place (element) in my document.
Once I have enough information collected in the first pass (for example, I have made sure there is indeed an ElementX with an id='1234'), I jump back to saved bookmarks (using those saved XPathNavigators) and complete the parsing.
Well, now I'm about to use this library in Silverlight 3.0 and to my horror the XPathNavigator is not in the System.Xml assembly.
Questions:
1) Am I missing something obvious (i.e. XPathNavigator does exist in some shape or form, for example in a toolkit or a freeware library)?
2) If I do have to make modifications in the code, what would be the best way to go? Ideally, I would like to make minimal changes, not to rewrite 80% of the code just to be able to use something like XLinq.
To resume, in case I have to give up XPathNavigator, all I need is a way to bookmark places in my document and to get back to them so that I can continue to iterate from where I left off.
Thanks in advance for any help/ideas.
You are not missing something obvious, there is no implementation of XPathNavigator or XPathDocument in the Silverlight versions of the libraries.
The "best way to go" is highly subjective and would really depend on how many lines of code are really depending on XPathNavigator. However I see a couple of choices.
Go ahead and re-write the code using XDocument, XElement etc from the System.Xml.Linq namepsace. This may not be as bad a choice as you might think.
Wrap Xml-to-Linq objects in your own implementation of those properties and methods of the XPathNavigator that you are actually using. It shouldn't be too hard re-create most the features of the XPathNavigator against the Xml-to-Linq objects. You can then run your existing code against your own XPathNavigator.
XPath (xdoc.XPathSelectElements) is available in Silverlight 4: here's an online test tool.
There are tons of ways:
How to deal with XML in C#
You can still use Linq to XML just minus the linq syntax and use the Linq Extension methods.

Resources