Detecting closed routes in orientdb - graph-databases

How can I detect closed routes (circles) following different types of edges in OrientDB?
Let me give an example. I have two types of vertices, Ideas and Persons, and I have two types of edges, submitted_by and commented_by. No I want to find all "co-commented" ideas. Two ideas are co-commented if the submitter of the one idea is the commentator of the other. My approach was to follow the outgoing commentator-edges, see what ideas these persons submitted, following again the commentators to these ideas and see whether the original idea is among these. My problem is that OrientDB doesn't allow me to use aliases for "from-expressions" like class names, and so I cannot compare the id of the first idea with the ids of the ideas I get when following the edges.
I have to say, that I'am completely new to OrientDB and also to GraphDBs in general. So maybe there is a simple answer to that problem. But an answer would definitely help me to better understand how you typically work with OrientDB and maybe that answer might be helpful for others as well.

Related

Question about deadly diamond problem (multiple inheritance)

I know in stackoverflow it has many people asked deadly diamond problem already, but the question that they asked is not what I want to ask, so could anyone please tell me what is the solution when I encounter this kind of problem.
The following picture (A) is a typical diamond problem , and (B) is the solution that change musician and actor from class to interface for achieving multiple inheritance. But what I want to ask is, how about if I also need musician and actor class? In general not all people are both musician and actor, some are only musician and some are only actor, if I change these 2 classes to interfaces, is that means if I need musician, I use Performer class to create object also? If so, why should I create Musician and Actor interface? Even consider future inheritance problem, as shown in (C), I don't think interface can help any code reusable, the only thing can help is about restrict person it must obey what musician interface have. I really get confuse of these 2 questions, can anyone please tell me in detail? Thank you very much for your help.
diamond problem image shown

Custom Searcher - Blending of hits from different sources

We have a need for "Blending of hits from different sources", as per your documentation it is recommended to write a custom-searcher in JAVA. Is there a demo of this written somewhere on Github ? I wouldn't even know where to start :( I understand I can create search "chains" , preferably Asynchronous, and then blend results in JAVA before returning them...but then how would I handle paginations, limits...etc ? This all seems very complicated, for someone who doesn't even know JAVA that much. So, I am hoping someone has already written a demo for this ? Please ? Anyone ?
Thank you so much
EDIT to make my quesion clearer:
We are writing a search engine that fetches data from various websites. Some websites have 10mil indexable items, other websites only 100,000. When we present the results to end user, we want to include results from all our sources ( when match applies ). Let's say 10 results from each of the websites we crawl, so that they all get equal amount of attention on page. If we don't do custom blending, what happens is that the largest website with most items wins all our traffic.
I understand that we can send 10 separate queries to VESPA, and blend the results in our front end, but that seems very inefficient. Thus, the quesion of "Custome Searcher". Thank you so much !
That documentation covers some very advanced use cases which you do not have. Are your sources different Vespa schemas or content clusters? If so Vespa will by default blend the hits returned from each according to their relevance scores so there's nothing you need to do.
The two other most common use-cases are:
Some (or all) the data sources are external, so you need to write a Searcher component to fetch the external data and turn it into a Result.
You want the data to be blended in some custom way (rather than by relevance score). If so you need to exclude the default blending Searcher (com.yahoo.prelude.searcher.BlendingSearcher) and write your own.
If you provide some more information about your use cases I can give you some code examples.
EDIT: Use grouping to solve the need explained under "EDIT" in the question:
Create a "siteid" field when feeding (e.g in document processing).
Use the grouping expression all(group(siteid) each(max(10) output(summary())))
See http://docs.vespa.ai/documentation/grouping.html

What does S[1..n] mean for strings and arrays?

I've chanced upon quite a few reference books using definitions stating "for the string S[1..n]" and "in the array A[0..n-1]", and I did look up several sites in related fields but am unable to figure out what this notation means. I know that this question is probably trivial to many and may have been answered prior to this question in a related post, but some help will be deeply appreciated as I'm pretty much stuck..

How to limit selection to one across several term reference fields?

I'm hoping somebody can help me.
I have added nine term reference fields, one for each of my vocabularies, to the Create New User page. What I want is to only allow one term to be selected from all nine term reference fields.
I realise that one way of doing this would be to combine the nine vocabularies into one and then choose to only allow the selection of one term. However, I would much prefer to keep my vocabularies separate.
I had a look at the Rules module but couldn't see an Action to fail the validation of a new user, even if I could test for empty fields etc.
I also had a look at the Conditional Fields module but again couldn't see a way to fail the validation.
Any help or pointers would be most gratefully received.
Many thanks,
Matt
I have managed to achieve what I wanted after discovering the excellent Rules Forms Support module. I ran into a bit of difficulty because there is no condition to check whether a form element is empty, only to compare it to a value. To overcome this I included the term 'None' to each vocabulary, set it as the default value and chose the field to be required. I was then able to set the condition to compare against this (tid) and it worked!
Hopefully this may be of help to someone someday.
Happy Drupaling to you,
Matt

Database moddelling - Trying to understand

Hey guys, I always get confused by this so it's not exactly my strong point :( Am I understanding correctly that the above example suggests:
One shop must have one or more clients
One client must have one shop
If there was to be a circle where at the end of the client arrow it suggests that the shop has zero or many clients.
I know it's a bad example but I am just trying to get my head around it. (Always get it the wrong way round)
Thanks very much, all help appreciated.
it's just a quick example so I apologise for the bad naming convention of table names
Yes, you are understanding correctly.

Resources