Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
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
Przemyslaw Kaminski
haskell-gargantext
Commits
d53349b4
Commit
d53349b4
authored
Dec 13, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Query] Search in Corpus To FacetDoc.
parent
905ef6b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
8 deletions
+6
-8
TextSearch.hs
src/Gargantext/Database/TextSearch.hs
+6
-8
No files found.
src/Gargantext/Database/TextSearch.hs
View file @
d53349b4
...
...
@@ -17,7 +17,7 @@ module Gargantext.Database.TextSearch where
import
Data.Aeson
import
Data.List
(
intersperse
)
import
Data.String
(
IsString
(
..
))
import
Data.Text
(
Text
,
words
,
unpack
)
import
Data.Text
(
Text
,
words
,
unpack
,
intercalate
)
import
Data.Time
(
UTCTime
)
import
Database.PostgreSQL.Simple
-- (Query, Connection)
import
Database.PostgreSQL.Simple.ToField
...
...
@@ -52,20 +52,18 @@ queryInDatabase _ q = proc () -> do
------------------------------------------------------------------------
-- | todo add limit and offset and order
searchInCorpus
::
Connection
->
CorpusId
->
Text
->
IO
[
FacetDoc
]
searchInCorpus
c
cId
q
=
map
toFacet
<$>
runQuery'
searchInCorpus
::
Connection
->
CorpusId
->
[
Text
]
->
Maybe
Offset
->
Maybe
Limit
->
Maybe
OrderBy
->
IO
[
FacetDoc
]
searchInCorpus
c
cId
q
o
l
order
=
runQuery
c
(
filterWith
o
l
order
$
queryInCorpus
cId
q'
)
where
toFacet
(
nId
,
d
,
h
)
=
FacetDoc
nId
d
(
maybe
"Empty Title"
identity
$
_hyperdataDocument_title
h
)
h
True
0
runQuery'
::
IO
[(
Int
,
UTCTime
,
HyperdataDocument
)]
runQuery'
=
runQuery
c
(
queryInCorpus
cId
q
)
q'
=
intercalate
" || "
$
map
stemIt
q
queryInCorpus
::
CorpusId
->
Text
->
O
.
Query
(
Column
PGInt4
,
Column
PGTimestamptz
,
Column
PGJsonb
)
queryInCorpus
::
CorpusId
->
Text
->
O
.
Query
FacetDocRead
queryInCorpus
cId
q
=
proc
()
->
do
(
n
,
nn
)
<-
joinInCorpus
-<
()
restrict
-<
(
nodeNode_node1_id
nn
)
.==
(
toNullable
$
pgInt4
cId
)
restrict
-<
(
_ns_search
n
)
@@
(
pgTSQuery
(
unpack
q
))
restrict
-<
(
_ns_typename
n
)
.==
(
pgInt4
$
nodeTypeId
NodeDocument
)
returnA
-<
(
_ns_id
n
,
_ns_date
n
,
_ns_hyperdata
n
)
returnA
-<
FacetDoc
(
_ns_id
n
)
(
_ns_date
n
)
(
_ns_name
n
)
(
_ns_hyperdata
n
)
(
pgBool
True
)
(
pgInt4
1
)
joinInCorpus
::
O
.
Query
(
NodeSearchRead
,
NodeNodeReadNull
)
joinInCorpus
=
leftJoin
queryNodeSearchTable
queryNodeNodeTable
cond
...
...
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