When I try to query:
select out('teaches') from Course
OrientDB returns empty lists, while the edges that I'm trying to find do exist.
Also, in the graph editor, the edges options won't show up anymore:
Normally, I can choose edges by hovering over the arrows. Now it doesn't do anything.
I've noticed that this started to happen when I started indexing my edges with a unique hash key. Does this have anything to do with it?
I'm using OrientDB version 2.0.5.
Apparently, it didn't work because I was using an UPDATE command.
UPDATE teaches SET in = #12:1, out = #13:1 UPSERT WHERE in = #12:1 AND out = #13:1 will create the edge (record) if it does not yet exist, but you won't be able to query it.
CREATE EDGE teaches from #13:1 to #12:1 does work and you will be able to query it.
Not sure whether this can be considered a bug...
Related
I have a unique constraint on edge:
CREATE CLASS hasAssignee extends E
CREATE PROPERTY hasAssignee.out LINK Assignable
CREATE PROPERTY hasAssignee.in LINK User
CREATE INDEX UniqueHasAssignee ON hasAssignee(out,in) UNIQUE
I want to multiple create edges if they don't yet exist in one query. If they do exist, then either replace them, or simply don't add them. Something like that, but without possibility of errors:
CREATE EDGE hasAssignee FROM ( SELECT FROM Project WHERE id=:id ) TO ( SELECT FROM User WHERE login in :login )
UPSERT from what I've noticed can deal with only one edge at a time (at least I couldn't produce query parsable by studio)
I see a few possibe solutions (but I don't see anything like it in docs):
something like CREATE IFNOTEXISTS
Soft indexes, that don't throw an error, simply don't create additional edges
Remove unique index, create duplicates, and somehow remove duplicates after each query (?)
Is it possible to do something like that in orientdb? Should I fill out a request?
There is an open feature request for this:
https://github.com/orientechnologies/orientdb/issues/4436
My suggestion is to vote on it
I'm working with OrientDB (2.2.10) and occasionaly I would like to visually inspect my dataset to make sure I'm doing things correctly. On this page of OrientDB http://orientdb.com/orientdb/ you see a nice visualization of a large graph with the following query:
select * from V limit -1;
So I tried the same query on my dataset but the result is so extremely sluggish that I can't work with it. My dataset is not extremely large (few hundred vertices, couple thousand edges) but still the result is unworkable. I tried all major browsers but with all I have the same result. Also my computer is not underpowered, I have a quad-core i7 with 16GB RAM.
As a very simple example I have the following graph:
BAR --WITHIN---> CITY --LOCATED_IN--> COUNTRY
Here: Find "friends of friends" with OrientDB SQL I was able to get at least an example of how to do this type of query on a graph. I managed to get a subset of my graph for example as follows:
select expand(
bothE('WITHIN').bothV()
) from Bar where barName='Foo' limit -1
This get's me the graph of 1 Bar vertex, the edge WITHIN and the City vertex. But if I now want to go one step further by also fetching the country which the city is located in I cannot get this style of query to work for me. I tried this:
select expand(
bothE('WITHIN').bothV()
.bothE('LOCATED_IN').bothV()
) from Bar where barName='Foo' limit -1
This results in the same subset being shown. However, if I first run the first query and then without clearing the canvas run the second query I do get the 3 vertices. So it seems I'm close but I would like to get all 3 vertices and it's edges in one query, not having to run first the one and then the other. Could someone point me in the right direction?
If you want to get all three vertices, it would be much easier start from the middle (city) and than get in and out to get bar and contry. I've tried with a similar little structure:
To get city, bar name and country you can try a query like this:
select name, in("WITHIN").name as barName,out("LOCATED_IN").name as barCountry from (select from City where name='Milan') unwind barName, barCountry
And the output will be:
Hope it helps.
If it is not suitable for your case, let me know.
You could use
traverse * from (select from bar where barName='Foo') while $depth <= 4
Example: I tried with this little graph
and I got
Hope it helps.
I am struggling to get the worldmap panel working with influxdb.
Can someone explain what I am doing wrong?
I am assuming that you have saved geohash as a tag.
If I run your query in a table panel, then I get two fields in the result called geohash and one of them is empty.
I think you can remove the field(geohash) from the select and get the result you want. (Or remove the last selector or change the alias so that there is no conflict between it and the group by).
Is there a way to create both a Vertex and Edge in the same query?
I am aware that we can use out_EdgeName/ in_EdgeName to update the edge of a vertex if it already exists in an UPDATE query, but how to do that so that a new edge is created and assigned to the vertex?
Example use case in an Update Upsert query - a Vertex is being created and we require a new Edge to be created for that vertex. Can we do it in the same query or we would need 2 queries at least for that (i.e 2 UPDATE - UPSERTS)?
Taking cue from orientdb sql update edge? :
Something like - UPDATE Persons SET phone=000000, out_Inside=(
UPDATE Edge UPSERT where in=#some_rid/sub-query, out=$this) where person_id=8
This question is actual if you are using new version of orientdb 2.1.
But as far as i know this features was implemented in 2.2 version.
"As far as I can tell, update works (including in/out):"
UPDATE FRIEND SET in=#11:5 WHERE in.name="Samantha" and out.name="Mat"
Although, using a query inside the set clause for in/out will cause it to return array:
UPDATE Friend SET in=(SELECT FROM User WHERE name="Jason") WHERE in.name="Samantha" and out.name="Mat"
Upsert also works, although when creating a new vertex it doesn't set the in/out properties.
You could set the in/out properties your self, like this:
UPDATE Friend SET comment="Wazzzaup", in=#11:5, out=#11:6 UPSERT WHERE in.name="Jason" AND out.name="Mat"
It will result in a longer query when using sub-query for in= and out=, but at least it works (sub-query has same problem as above).
I got this information from issue:
https://github.com/orientechnologies/orientdb/issues/1114#issuecomment-156585776
I am working on a project where we are going to be looking at finding the shortest/fastest route from point A to point B. I've been looking at the tables generated by the osm2pgsql. And I'm wondering how would I represent a road obstructed after the osm has been loaded into our database. Our project will rely on osm to map out all of the roads we will also have an operator looking at live video footage of roads. At which point if the operator see's a road is obstructed we want to update the database to reflect this road obstructed say by a downed tree.
I've been looking at all of the columns and the only one that stands out in my head is barrier. I have been unable to find any documentation on what each column represents and how pg_route takes each into consideration when creating a route. What I'm looking for is a column that when pg_route looks in the database and sees a road it says oh that roads blocked skip it?
This is good question for gis.se...
First thing is pg_routing can't route via data generated by osm2pgsql - this data is not a network. You need data generated by osm2po or osm2pgrouting and this data is quite different.
Second thing is - there is no such column. In every pg_routing function you're passing sql which will select data for route search so you're deciding which edge will be in this dataset and which not - it's not a problem to add extra column to table with edges.
Here is link to pgrouting workshop it will guide you through all process from import of data to first generated route. It's using osm2pgroutin to import data, but I suggest you use osm2po instead.
So as Jendrusk mentioned, when you generate a route you will pass the function a SQL query to select the edges for the graph you want to solve, 'select * from edges where the_geom && <bbox>' You can model blockages using point and radius, lines, or polygons that you want the route to avoid by adding to the query above avoidance zones like:
'select * from edges where the_geom && <bbox> and not st_dwithin(the_geom, point, radius) and not stdwithin(the_geom, line_or_polygon, 0.0)'
If you have lots of these avoidances then put them in a table and do a join to eliminate the edges that are used to build the graph. If the edges are not there the route is forces to find a way around the avoidance.