Re: [orientdb] Regarding Single Query To fetch out all the combination as a result

10 views
Skip to first unread message

Chaitanya deep singh Jhala

unread,
Apr 19, 2017, 6:00:32 AM4/19/17
to OrientDB
Thanks for your quick response.Somewhere I am looking for the same result down the line.One small doubt if we have more then one dependent Vertex then how we will put it into the same query like Server IsMountedOn Storage and Server IsConnectedTo Network.

On Tuesday, April 18, 2017 at 6:07:35 PM UTC+5:30, Luigi Dell'Aquila wrote:
OK, got it, if you only need the RIDs of the involved elements, you can do the following:


MATCH
  {as:user} -Performs-> {as:process} -Uses->
  {class:Application, as:app, where:(applicationName = ?)} -RunsOn-> {class:Server, as:server, where:(osType = ?)}
RETURN user, process, app, server

If you also want all the details in line, you can use an outer SELECT:

SELECT user.* as user_, process.* as process_, app.* as app_, server.* as server_ FROM (
  MATCH
    {as:user} -Performs-> {as:process} -Uses->
    {class:Application, as:app, where:(applicationName = ?)} -RunsOn-> {class:Server, as:server, where:(osType = ?)}
  RETURN user.nameprocess.idapp.name, server.url, server.name  
)

The "as xxx_" will add a prefix to attributes, this is useful to avoid collisions, eg. if you have user.name and server.name, this way you will have "user_name" and "server_name"

If you don't need all the patterns, but you only need single records that are part of the result, you can try the following:


MATCH
  {as:user} -Performs-> {as:process} -Uses->
  {class:Application, as:app, where:(applicationName = ?)} -RunsOn-> {class:Server, as:server, where:(osType = ?)}
RETURN $elements

Thanks

Luigi


2017-04-18 14:30 GMT+02:00 Chaitanya deep singh Jhala <chaita...@gmail.com>:
Hi Luigi

Thanks for your quick response.

Actually I don't want to mention any details related to the Vertex.
Suppose for User vertex I have 5 attributes, same as for Process vertex I have 3 attributes, So, If these two Vertex are related to osType and applicationName then i want all the details of Vertex attributes without mentioning attribute details.
Example :
In simple sql query we are writing Select * from User and we will get all the details of User.

Hope you are understand what I am actually looking for.

Thanks
Chaitanya

On Tuesday, April 18, 2017 at 5:42:31 PM UTC+5:30, Luigi Dell'Aquila wrote:
Hi,

A MATCH statement is what you need:

MATCH
  {as:user} -Performs-> {as:process} -Uses->
  {class:Application, as:app, where:(applicationName = ?)} -RunsOn-> {class:Server, as:server, where:(osType = ?)}
RETURN user.name, process.id, app.name, server.url, server.name  
/* just add here all the info you need */


I hope it helps

Thanks

Luigi




2017-04-18 14:00 GMT+02:00 Chaitanya deep singh Jhala <chaita...@gmail.com>:
Hi

I have some doubts related to the queries in orientdb. I have below scenario :

Example :

       Performs              Uses                    RunsOn
User     -->    Process    -->    Application     -->      Server

Here , User/Process/Application/Server  are Vertex Names
          Performs/Uses/RunsOn are Edge Names

Now, I want all the related combination result as per the input.if input is like osType of Server and applicationName of Application then i want all the details related to this two inputs like user and process and whatever is related to this applicationName and osType.

It is possible in orientdb to fetch out all this details in a single query ??


Thanks & Regards
Chaitanya

--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luigi Dell'Aquila

unread,
Apr 19, 2017, 6:10:07 AM4/19/17
to orient-...@googlegroups.com
Hi, 

You can add multiple comma separated patters. Use aliases an junction points eg.

MATCH
  {as:user} -Performs-> {as:process} -Uses->
  {class:Application, as:app, where:(applicationName = ?)} -RunsOn-> {class:Server, as:server, where:(osType = ?)},
  {as:server} -IsMoutedOn-> {as:storage},
  {as:server} -IsConnectedTo-> {as:network}
RETURN $elements


Thanks

Luigi

To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages