Commit 925d678b authored by Alexandre Delanoë's avatar Alexandre Delanoë

Revert "[search] implement ts_query search"

This reverts commit 29ee1972.

It introduces a bug, it should not be merged.
parent d2fdd956
......@@ -38,9 +38,6 @@ CREATE TABLE public.nodes (
FOREIGN KEY (user_id) REFERENCES public.auth_user(id) ON DELETE CASCADE
);
ALTER TABLE public.nodes OWNER TO gargantua;
ALTER TABLE nodes
ADD COLUMN search_title tsvector
GENERATED ALWAYS AS (to_tsvector('english', coalesce("name", '') || ' ' || coalesce("hyperdata"->>'abstract', ''))) STORED;
--------------------------------------------------------------
-- | Ngrams
......
......@@ -24,6 +24,7 @@ import Gargantext.Database.Prelude (Cmd, execPGSQuery)
import Gargantext.Prelude
import qualified Database.PostgreSQL.Simple as DPS
triggerSearchUpdate :: HasDBid NodeType => Cmd err Int64
triggerSearchUpdate = execPGSQuery query ( toDBid NodeDocument
, toDBid NodeDocument
......
......@@ -44,8 +44,6 @@ import Control.Arrow (returnA)
import Control.Lens ((^.))
import Data.Aeson (FromJSON, ToJSON)
import Data.Aeson.TH (deriveJSON)
import qualified Database.PostgreSQL.Simple as DPS
import Database.PostgreSQL.Simple.SqlQQ (sql)
import Data.Profunctor.Product.TH (makeAdaptorAndInstance)
import Data.Swagger
import qualified Data.Text as T
......@@ -70,9 +68,6 @@ import Gargantext.Database.Query.Table.NodeNodeNgrams
import Gargantext.Database.Prelude
import Gargantext.Database.Schema.Node
--import qualified Opaleye.Internal.Column as C
--import qualified Opaleye.Internal.HaskellDB.PrimQuery as HPQ
------------------------------------------------------------------------
-- | DocFacet
......@@ -307,30 +302,11 @@ runViewDocuments :: HasDBid NodeType
-> Maybe OrderBy
-> Maybe Text
-> Cmd err [FacetDoc]
runViewDocuments cId t _o _l _order query = do
docs <- runPGSQuery viewDocuments'
( cId
, ntId
, (if t then 0 else 1) :: Int
, fromMaybe "" query
, fromMaybe "" query)
pure $ (\(id, date, name', hyperdata, category, score) -> FacetDoc id date name' hyperdata category score score) <$> docs
-- runOpaQuery $ filterWith o l order sqlQuery
runViewDocuments cId t o l order query = do
runOpaQuery $ filterWith o l order sqlQuery
where
ntId :: Int
ntId = toDBid NodeDocument
-- sqlQuery = viewDocuments cId t ntId query
viewDocuments' :: DPS.Query
viewDocuments' = [sql|
SELECT n.id, n.date, n.name, n.hyperdata, nn.category, nn.score
FROM nodes AS n
JOIN nodes_nodes AS nn
ON n.id = nn.node2_id
WHERE nn.node1_id = ? -- corpusId
AND n.typename = ? -- NodeTypeId
AND nn.category = ? -- isTrash or not
AND (n.search_title @@ to_tsquery(?) OR ? = '') -- query with an OR hack for empty to_tsquery('') results
|]
sqlQuery = viewDocuments cId t ntId query
runCountDocuments :: HasDBid NodeType => CorpusId -> IsTrash -> Maybe Text -> Cmd err Int
runCountDocuments cId t mQuery = do
......
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