[ngrams] fix score ordering

parent 534d0f6e
...@@ -45,7 +45,6 @@ library ...@@ -45,7 +45,6 @@ library
Gargantext.API.Node.Share Gargantext.API.Node.Share
Gargantext.API.Prelude Gargantext.API.Prelude
Gargantext.Core Gargantext.Core
Gargantext.Core.NLP
Gargantext.Core.Methods.Similarities Gargantext.Core.Methods.Similarities
Gargantext.Core.NLP Gargantext.Core.NLP
Gargantext.Core.NodeStory Gargantext.Core.NodeStory
......
...@@ -136,6 +136,7 @@ runViewDocuments cId t o l order query year = do ...@@ -136,6 +136,7 @@ runViewDocuments cId t o l order query year = do
remapNgramsCount (FacetDoc { .. }) = remapNgramsCount (FacetDoc { .. }) =
FacetDoc { facetDoc_ngramCount = Just $ fromIntegral facetDoc_ngramCount FacetDoc { facetDoc_ngramCount = Just $ fromIntegral facetDoc_ngramCount
, facetDoc_score = Just $ fromIntegral facetDoc_score
, .. } , .. }
runCountDocuments :: (HasDBid NodeType, HasNodeError err) runCountDocuments :: (HasDBid NodeType, HasNodeError err)
...@@ -160,7 +161,7 @@ viewDocuments cId lId t ntId mQuery mYear = ...@@ -160,7 +161,7 @@ viewDocuments cId lId t ntId mQuery mYear =
, facetDoc_hyperdata = OAgg.groupBy , facetDoc_hyperdata = OAgg.groupBy
, facetDoc_category = OAgg.groupBy , facetDoc_category = OAgg.groupBy
, facetDoc_ngramCount = OAgg.sumInt4 , facetDoc_ngramCount = OAgg.sumInt4
, facetDoc_score = OAgg.sum }) , facetDoc_score = OAgg.sumInt4 })
(viewDocumentsAgg cId lId t ntId mQuery mYear) (viewDocumentsAgg cId lId t ntId mQuery mYear)
viewDocumentsAgg :: CorpusId viewDocumentsAgg :: CorpusId
...@@ -175,14 +176,18 @@ viewDocumentsAgg cId lId t ntId mQuery mYear = proc () -> do ...@@ -175,14 +176,18 @@ viewDocumentsAgg cId lId t ntId mQuery mYear = proc () -> do
cnng <- optionalRestrict queryContextNodeNgramsTable -< cnng <- optionalRestrict queryContextNodeNgramsTable -<
\cnng' -> (cnng' ^. cnng_node_id) .== pgNodeId lId .&& -- (nc ^. nc_node_id) .&& \cnng' -> (cnng' ^. cnng_node_id) .== pgNodeId lId .&& -- (nc ^. nc_node_id) .&&
(cnng' ^. cnng_context_id) .== (c ^. cs_id) (cnng' ^. cnng_context_id) .== (c ^. cs_id)
let ngramCount = fromMaybeFields 0 $ _cnng_doc_count <$> cnng
returnA -< FacetDoc { facetDoc_id = _cs_id c returnA -< FacetDoc { facetDoc_id = _cs_id c
, facetDoc_created = _cs_date c , facetDoc_created = _cs_date c
, facetDoc_title = _cs_name c , facetDoc_title = _cs_name c
, facetDoc_hyperdata = _cs_hyperdata c , facetDoc_hyperdata = _cs_hyperdata c
, facetDoc_category = nc ^. nc_category , facetDoc_category = nc ^. nc_category
, facetDoc_ngramCount = fromMaybeFields 0 $ _cnng_doc_count <$> cnng -- toNullable $ nc^.nc_score , facetDoc_ngramCount = ngramCount
-- , facetDoc_ngramCount = toNullable $ toFields cnt -- NOTE This is a slight abuse of "score" but
, facetDoc_score = nc ^. nc_score -- currently it is all 0's in the DB and the
-- search functionality on the frontend orders
-- by Score.
, facetDoc_score = ngramCount
} }
-- TODO Join with context_node_ngrams at context_id/node_id and sum by -- TODO Join with context_node_ngrams at context_id/node_id and sum by
......
...@@ -31,7 +31,7 @@ type Title = Text ...@@ -31,7 +31,7 @@ type Title = Text
-- TODO remove Title -- TODO remove Title
type FacetDoc = Facet NodeId UTCTime Title HyperdataDocument (Maybe Category) (Maybe Double) (Maybe Score) type FacetDoc = Facet NodeId UTCTime Title HyperdataDocument (Maybe Category) (Maybe Double) (Maybe Score)
type FacetDocAgg' = Facet NodeId UTCTime Title HyperdataDocument (Maybe Category) Int64 (Maybe Score) type FacetDocAgg' = Facet NodeId UTCTime Title HyperdataDocument (Maybe Category) Int64 Int64
-- type FacetSources = FacetDoc -- type FacetSources = FacetDoc
-- type FacetAuthors = FacetDoc -- type FacetAuthors = FacetDoc
-- type FacetTerms = FacetDoc -- type FacetTerms = FacetDoc
...@@ -144,7 +144,7 @@ type FacetDocAgg = Facet (Field SqlInt4 ) ...@@ -144,7 +144,7 @@ type FacetDocAgg = Facet (Field SqlInt4 )
(Field SqlJsonb ) (Field SqlJsonb )
(Field SqlInt4) -- Category (Field SqlInt4) -- Category
(Field SqlInt8) -- Ngrams Count (Field SqlInt8) -- Ngrams Count
(Field SqlFloat8) -- Score (Field SqlInt8) -- Score
type FacetDocAggPart = Facet (Field SqlInt4 ) type FacetDocAggPart = Facet (Field SqlInt4 )
(Field SqlTimestamptz) (Field SqlTimestamptz)
...@@ -152,7 +152,7 @@ type FacetDocAggPart = Facet (Field SqlInt4 ) ...@@ -152,7 +152,7 @@ type FacetDocAggPart = Facet (Field SqlInt4 )
(Field SqlJsonb ) (Field SqlJsonb )
(Field SqlInt4) -- Category (Field SqlInt4) -- Category
(Field SqlInt4) -- Ngrams Count (Field SqlInt4) -- Ngrams Count
(Field SqlFloat8) -- Score (Field SqlInt4) -- Score
----------------------------------------------------------------------- -----------------------------------------------------------------------
----------------------------------------------------------------------- -----------------------------------------------------------------------
......
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