Commit ac77596e authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

Merge branch 'dev-ilike-search-fix' into dev-corpora-from-write-nodes

parents 2ba1b298 c2ba2f72
Pipeline #1925 canceled with stage
......@@ -38,10 +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 IF NOT EXISTS search_title tsvector;
UPDATE nodes SET search_title = to_tsvector('english', coalesce("hyperdata"->>'title', '') || ' ' || coalesce("hyperdata"->>'abstract', ''));
CREATE INDEX IF NOT EXISTS search_title_idx ON nodes USING GIN (search_title);
--------------------------------------------------------------
-- | Ngrams
CREATE TABLE public.ngrams (
......
......@@ -48,7 +48,7 @@ import GHC.Generics (Generic)
import Gargantext.Core.Utils.Prefix (unPrefix, unPrefixSwagger, wellNamedSchema)
import Gargantext.Database.Prelude (fromField')
import Gargantext.Prelude
import Opaleye (DefaultFromField(..), PGJsonb, defaultFromField, fieldQueryRunnerColumn, Nullable)
import Opaleye (DefaultFromField, defaultFromField, PGJsonb, fieldQueryRunnerColumn, Nullable)
import Test.QuickCheck (elements)
import Test.QuickCheck.Arbitrary hiding (vector)
......
......@@ -141,7 +141,6 @@ instance (Arbitrary hyperdata
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
------------------------------------------------------------------------
pgNodeId :: NodeId -> O.Column O.PGInt4
......
......@@ -329,7 +329,7 @@ runViewDocuments cId t o l order query = do
-- 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
-- AND (n.search @@ to_tsquery(?) OR ? = '') -- query with an OR hack for empty to_tsquery('') results
-- |]
runCountDocuments :: HasDBid NodeType => CorpusId -> IsTrash -> Maybe Text -> Cmd err Int
......@@ -359,8 +359,8 @@ viewDocuments cId t ntId mQuery = proc () -> do
-- restrict -< (n^.node_name) `ilike` (sqlStrictText iLikeQuery)
restrict -< if query == ""
then pgBool True
--else (n^.ns_search_title) @@ (pgTSQuery (T.unpack query))
else (n^.ns_search_title) @@ (toTSQuery $ T.unpack query)
--else (n^.ns_search) @@ (pgTSQuery (T.unpack query))
else (n^.ns_search) @@ (toTSQuery $ T.unpack query)
returnA -< FacetDoc (_ns_id n)
(_ns_date n)
......
......@@ -154,7 +154,6 @@ data NodePolySearch id
, _ns_hyperdata :: hyperdata
, _ns_search :: search
, _ns_search_title :: search
} deriving (Show, Generic)
$(makeAdaptorAndInstance "pNodeSearch" ''NodePolySearch)
......@@ -174,7 +173,6 @@ nodeTableSearch = Table "nodes" ( pNodeSearch
, _ns_hyperdata = requiredTableField "hyperdata"
, _ns_search = optionalTableField "search"
, _ns_search_title = optionalTableField "search_title"
}
)
------------------------------------------------------------------------
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