I think the answer is no, but i still want to confirm
My use case is as follows:
1)Get sub graph between source and destination.
2)Then for each node in subgraph obtained in step 1 , do some aggregation
Some thing like
select nodeId, sum(mycount) where prop ="value" and prop2 ="value2" and nodeId in [x,y,z ] group by nodeId
Can u do this in orinet DB ?If yes how efficiently?
Group by is supported and it's fast. Have you tried it?
Related
I am a newbie to sphinxsearch. But I learned to configure the conf and delta conf.
My doubt: I recently I came through a conf which has the same query in mainconf as well as deltaconf.
sample
main_conf:
{
#...
sql_query = select a,b,c from documents group by c
#...
}
delta_conf : main_conf
{
#...
sql_query_killlist = select a from documents where date_updated > '2015-08-01 23:30:00'
sql_query = select a,b,c from documents group by c
#...
}
I need the understand how this works exactly. Will there be a duplication of data in the delta conf which was there in the main conf. How this works on indexing.
Thanks in advance.
Please be kind enough to answer this even if the question is basic.
The answer I got from sphinxsearch forum. And I think it's clear
Will there be a duplication of data
Yes. As it stands.
You need to modify the delta sql_query to only include the new/updated records - the ones
NOT in the main index.
(the kill list is there to 'remove' the ones that need to be duplicated (because they
updated) from the main. If a record needs to be in both indexes, use killlist to return
it back to one)
I've got a bit of a semantic question about Orient SQL queries.
Take for example this very simple graph:
v(#12:1 User) --> e(#13:1 FriendOf) --> v(#12:2 User)
In other words, a given User with an rid of #12:1 is friends with another user with an rid of #12:2.
To get the friends of user #12:1, one might express this in Orient SQL like so:
SELECT EXPAND(both("FriendOf")) FROM #12:1
This query would return a result list comprised of the User with rid #12:2.
Now lets say I want to filter that result list by an additional criteria, like say a numeric value ("age"):
SELECT EXPAND(both("FriendOf")) FROM #12:1 WHERE age >= 10
The above query would filter the CURRENT vertex (#12:1), NOT the result set. Which makes sense, but is there a way to apply the filter to the EXPAND(both("FriendOf")) result rather than the current vertex? I know I can do this with gremlin like so:
SELECT EXPAND(gremlin('current.both("FriendOf").has("age",T.gte,10)')) FROM #12:1
But the above does not seem to make use of indexes (at least not when I ask it to explain). For very large data sets, this is problematic.
So is there a proper way to apply a WHERE statement to the resulting data set?
Thanks !
... is there a way to apply the filter to the EXPAND(both("FriendOf")) result rather than the current vertex?
The simple answer is to embed your basic "SELECT EXPAND ..." within another SELECT, i.e.
SELECT FROM (SELECT EXPAND(both("FriendOf")) FROM #12:1) WHERE age >= 10
By the way, on my Mac, the above took .005s compared to over 2s for the Gremlin version. There must be a moral there somewhere :-)
I have a node with id 1 and a node with id 2 in the database and they are linked to each other. Why when I run this query
MATCH (a)-[r]-(b) WHERE id(a)=1 AND id(b)=2 RETURN *;
Nothing is returned?
Solution
I use GrapheneDB. Usually GrapheneDB presents the system node id on the node graphic but when you have an attribute id it presents that instead. When I ran the query I was using the graphic id which wasn't actually the system id so id(a) didn't give the expected result.
Because the WHERE clause is evaluated for each candidate result, and the entire clause must evaluate to true.
Also, putting MATCH (a)-[r]-(b) will only find parts of the graph where those two nodes are related.
If you just want to find nodes 1 and 2, you can do this:
MATCH n
WHERE id(n) = 1 OR id(n) = 2
RETURN n
However, you should not be using node ids. They are deprecated, and being phased out. There are lots of other ways to find and identify nodes that don't rely on their internal identifier. If you open a new question with your actual scenario, we could help you write a better query.
What differences are there between group by and group sort?
How to implement set select in sphinx SE?
groupby: what function and attribute to use for grouping
groupsort: what order to retrieve the groups in.
use 'select'. But be careful that your sphinxSE table has the right columns to use the output
(btw, its sphinxSE not "sphinx SE")
Example:
SELECT `cat`.`id_catalog`, COUNT(parent.id_catalog) - 1) AS `level` FROM `tbl_catalog` AS `cat`, `tbl_catalog` AS `parent` WHERE (cat.`left` BETWEEN parent.`left` AND parent.`right`) GROUP BY `cat`.`id_catalog` ORDER BY `cat`.`left` ASC
It doesn't seem to work if it use ZF. ZF create this query with join only. How to create the select without join in ZF_DB.
By the way may be I do smth wrong in this query. It is simple nested set DB with parent, left and right fields. Perhaps there are another way to use join to get deep for some node. Anyway it would be interesting to get answer for both way:)
Thanks in advance to all who looks it through:)