Commit a6789f09 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] #199

parent d7feabb9
...@@ -122,31 +122,29 @@ getOccByNgramsOnlyFast cId lId nt = do ...@@ -122,31 +122,29 @@ getOccByNgramsOnlyFast cId lId nt = do
-> Cmd err [(Text, DPST.PGArray Int)] -> Cmd err [(Text, DPST.PGArray Int)]
run cId' lId' nt' = runPGSQuery query run cId' lId' nt' = runPGSQuery query
( cId' ( cId'
, cId'
, lId' , lId'
, ngramsTypeId nt' , ngramsTypeId nt'
) )
query :: DPS.Query query :: DPS.Query
query = [sql| query = [sql|
SELECT ng.terms WITH node_context_ids AS
, ARRAY( (select context_id, ngrams_id
SELECT DISTINCT context_node_ngrams.context_id FROM context_node_ngrams_view
FROM context_node_ngrams WHERE node_id = ?
JOIN nodes_contexts ), ns AS
ON context_node_ngrams.context_id = nodes_contexts.context_id (select ngrams_id FROM node_stories
WHERE ng.id = context_node_ngrams.ngrams_id WHERE node_id = ? AND ngrams_type_id = ?
AND nodes_contexts.node_id = ? )
) AS context_ids
SELECT ng.terms,
ARRAY ( SELECT DISTINCT context_id
FROM node_context_ids
WHERE ns.ngrams_id = node_context_ids.ngrams_id
)
AS context_ids
FROM ngrams ng FROM ngrams ng
JOIN node_stories ns ON ng.id = ns.ngrams_id JOIN ns ON ng.id = ns.ngrams_id
JOIN node_node_ngrams nng ON ns.node_id = nng.node2_id
WHERE nng.node1_id = ?
AND nng.node2_id = ?
AND nng.ngrams_type = ?
AND nng.ngrams_id = ng.id
AND nng.ngrams_type = ns.ngrams_type_id
ORDER BY ng.id ASC;
|] |]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment