Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Christian Merten
haskell-gargantext
Commits
1d311b08
Commit
1d311b08
authored
Sep 10, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[search] include search in abstract for documents
parent
eed1436a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
22 deletions
+21
-22
Search.hs
src/Gargantext/Database/Action/Search.hs
+8
-16
Facet.hs
src/Gargantext/Database/Query/Facet.hs
+13
-6
No files found.
src/Gargantext/Database/Action/Search.hs
View file @
1d311b08
...
...
@@ -39,8 +39,7 @@ import Data.Profunctor.Product (p4)
import
qualified
Opaleye
as
O
hiding
(
Order
)
------------------------------------------------------------------------
searchDocInDatabase
::
HasDBid
NodeType
=>
ParentId
searchDocInDatabase
::
ParentId
->
Text
->
Cmd
err
[(
NodeId
,
HyperdataDocument
)]
searchDocInDatabase
p
t
=
runOpaQuery
(
queryDocInDatabase
p
t
)
...
...
@@ -55,8 +54,7 @@ searchDocInDatabase p t = runOpaQuery (queryDocInDatabase p t)
------------------------------------------------------------------------
-- | todo add limit and offset and order
searchInCorpus
::
HasDBid
NodeType
=>
CorpusId
searchInCorpus
::
CorpusId
->
IsTrash
->
[
Text
]
->
Maybe
Offset
...
...
@@ -69,8 +67,7 @@ searchInCorpus cId t q o l order = runOpaQuery
$
intercalate
" | "
$
map
stemIt
q
searchCountInCorpus
::
HasDBid
NodeType
=>
CorpusId
searchCountInCorpus
::
CorpusId
->
IsTrash
->
[
Text
]
->
Cmd
err
Int
...
...
@@ -79,8 +76,7 @@ searchCountInCorpus cId t q = runCountOpaQuery
$
intercalate
" | "
$
map
stemIt
q
queryInCorpus
::
HasDBid
NodeType
=>
CorpusId
queryInCorpus
::
CorpusId
->
IsTrash
->
Text
->
O
.
Query
FacetDocRead
...
...
@@ -108,8 +104,7 @@ joinInCorpus = leftJoin queryNodeSearchTable queryNodeNodeTable cond
------------------------------------------------------------------------
searchInCorpusWithContacts
::
HasDBid
NodeType
=>
CorpusId
::
CorpusId
->
AnnuaireId
->
[
Text
]
->
Maybe
Offset
...
...
@@ -125,8 +120,7 @@ searchInCorpusWithContacts cId aId q o l _order =
$
map
stemIt
q
selectContactViaDoc
::
HasDBid
NodeType
=>
CorpusId
::
CorpusId
->
AnnuaireId
->
Text
->
QueryArr
()
...
...
@@ -148,8 +142,7 @@ selectContactViaDoc cId aId q = proc () -> do
,
toNullable
$
pgInt4
1
)
selectGroup
::
HasDBid
NodeType
=>
NodeId
selectGroup
::
NodeId
->
NodeId
->
Text
->
Select
FacetPairedReadNull
...
...
@@ -267,8 +260,7 @@ textSearchQuery = "SELECT n.id, n.hyperdata->'publication_year' \
-- Example:
-- textSearchTest :: ParentId -> TSQuery -> Cmd err [(Int, Value, Value, Value, Value, Maybe Int)]
-- textSearchTest pId q = textSearch q pId 5 0 Asc
textSearch
::
HasDBid
NodeType
=>
TSQuery
->
ParentId
textSearch
::
TSQuery
->
ParentId
->
Limit
->
Offset
->
Order
->
Cmd
err
[(
Int
,
Value
,
Value
,
Value
,
Value
,
Maybe
Int
)]
textSearch
q
p
l
o
ord
=
runPGSQuery
textSearchQuery
(
q
,
p
,
p
,
typeId
,
ord
,
o
,
l
)
...
...
src/Gargantext/Database/Query/Facet.hs
View file @
1d311b08
...
...
@@ -59,6 +59,7 @@ import qualified Opaleye.Internal.Unpackspec()
import
Gargantext.Core
import
Gargantext.Core.Types
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
,
wellNamedSchema
)
import
Gargantext.Database.Admin.Config
()
-- HasDBid NodeType
import
Gargantext.Database.Admin.Types.Hyperdata
import
Gargantext.Database.Query.Filter
import
Gargantext.Database.Query.Join
(
leftJoin5
)
...
...
@@ -67,6 +68,7 @@ import Gargantext.Database.Query.Table.NodeNode
import
Gargantext.Database.Query.Table.NodeNodeNgrams
import
Gargantext.Database.Prelude
import
Gargantext.Database.Schema.Node
--import Gargantext.Prelude (printDebug)
------------------------------------------------------------------------
-- | DocFacet
...
...
@@ -305,22 +307,23 @@ runViewDocuments :: HasDBid NodeType
runViewDocuments
cId
t
o
l
order
query
=
do
runOpaQuery
$
filterWith
o
l
order
sqlQuery
where
ntId
=
toDBid
NodeDocument
sqlQuery
=
viewDocuments
cId
t
ntId
query
sqlQuery
=
viewDocuments
cId
t
query
runCountDocuments
::
HasDBid
NodeType
=>
CorpusId
->
IsTrash
->
Maybe
Text
->
Cmd
err
Int
runCountDocuments
cId
t
mQuery
=
do
--printDebug "[runViewDocuments] query" $ showSql sqlQuery
runCountOpaQuery
sqlQuery
where
sqlQuery
=
viewDocuments
cId
t
(
toDBid
NodeDocument
)
mQuery
sqlQuery
=
viewDocuments
cId
t
mQuery
viewDocuments
::
CorpusId
->
IsTrash
->
NodeTypeId
->
Maybe
Text
->
Query
FacetDocRead
viewDocuments
cId
t
ntId
mQuery
=
proc
()
->
do
viewDocuments
cId
t
mQuery
=
proc
()
->
do
let
ntId
=
toDBid
NodeDocument
n
<-
queryNodeTable
-<
()
nn
<-
queryNodeNodeTable
-<
()
restrict
-<
n
^.
node_id
.==
nn
^.
nn_node2_id
...
...
@@ -331,7 +334,11 @@ viewDocuments cId t ntId mQuery = proc () -> do
let
query
=
(
fromMaybe
""
mQuery
)
iLikeQuery
=
T
.
intercalate
""
[
"%"
,
query
,
"%"
]
restrict
-<
(
n
^.
node_name
)
`
ilike
`
(
pgStrictText
iLikeQuery
)
restrict
-<
((
n
^.
node_name
)
`
ilike
`
(
pgStrictText
iLikeQuery
))
.||
((
fromNullable
(
pgStrictText
""
)
((
toNullable
$
n
^.
node_hyperdata
)
.->>
(
pgStrictText
"source"
)))
`
ilike
`
(
pgStrictText
iLikeQuery
))
--((n^.node_hyperdata .:? "source") `ilike` (pgStrictText iLikeQuery))
-- NOTE Title is under node_name
-- Abstract is under node_hyperdata -> source
returnA
-<
FacetDoc
(
_node_id
n
)
(
_node_date
n
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment