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
197
Issues
197
List
Board
Labels
Milestones
Merge Requests
11
Merge Requests
11
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
gargantext
haskell-gargantext
Commits
949c4225
Verified
Commit
949c4225
authored
Sep 09, 2025
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[search] small refactoring of the search API
parent
e3a333b8
Pipeline
#7873
passed with stages
in 65 minutes and 36 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
23 deletions
+32
-23
Search.hs
src/Gargantext/API/Search.hs
+30
-22
Search.hs
src/Gargantext/Database/Action/Search.hs
+2
-1
No files found.
src/Gargantext/API/Search.hs
View file @
949c4225
...
@@ -24,11 +24,13 @@ import Gargantext.API.Prelude (IsGargServer)
...
@@ -24,11 +24,13 @@ import Gargantext.API.Prelude (IsGargServer)
import
Gargantext.API.Routes.Named.Search
qualified
as
Named
import
Gargantext.API.Routes.Named.Search
qualified
as
Named
import
Gargantext.API.Search.Types
(
SearchQuery
(
..
),
SearchResult
(
..
),
SearchResultTypes
(
..
),
SearchType
(
..
))
import
Gargantext.API.Search.Types
(
SearchQuery
(
..
),
SearchResult
(
..
),
SearchResultTypes
(
..
),
SearchType
(
..
))
import
Gargantext.Core.Text.Corpus.Query
(
RawQuery
(
..
),
parseQuery
)
import
Gargantext.Core.Text.Corpus.Query
(
RawQuery
(
..
),
parseQuery
)
import
Gargantext.Core.Types.Query
(
Limit
,
Offset
)
import
Gargantext.Core.Types.Search
(
toRow
)
import
Gargantext.Core.Types.Search
(
toRow
)
import
Gargantext.Database.Action.Flow.Pairing
(
isPairedWith
)
import
Gargantext.Database.Action.Flow.Pairing
(
isPairedWith
)
import
Gargantext.Database.Action.Search
(
searchInCorpus
,
searchInCorpusWithContacts
)
import
Gargantext.Database.Action.Search
(
searchInCorpus
,
searchInCorpusWithContacts
)
import
Gargantext.Database.Admin.Types.Node
(
NodeId
,
NodeType
(
..
))
import
Gargantext.Database.Admin.Types.Node
(
NodeId
,
NodeType
(
..
))
import
Gargantext.Database.Prelude
import
Gargantext.Database.Prelude
import
Gargantext.Database.Query.Facet
(
OrderBy
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.System.Logging
(
logLocM
,
LogLevel
(
..
))
import
Gargantext.System.Logging
(
logLocM
,
LogLevel
(
..
))
import
Servant.Server.Generic
(
AsServerT
)
import
Servant.Server.Generic
(
AsServerT
)
...
@@ -38,26 +40,32 @@ import Servant.Server.Generic (AsServerT)
...
@@ -38,26 +40,32 @@ import Servant.Server.Generic (AsServerT)
-- TODO-EVENTS: No event, this is a read-only query.
-- TODO-EVENTS: No event, this is a read-only query.
-- | Api search function
-- | Api search function
api
::
IsGargServer
env
err
m
=>
NodeId
->
Named
.
SearchAPI
SearchResult
(
AsServerT
m
)
api
::
IsGargServer
env
err
m
=>
NodeId
->
Named
.
SearchAPI
SearchResult
(
AsServerT
m
)
api
nId
=
Named
.
SearchAPI
$
\
query
o
l
order
->
case
query
of
api
nId
=
Named
.
SearchAPI
{
searchEp
=
searchEp
nId
}
(
SearchQuery
rawQuery
SearchDoc
)
->
case
parseQuery
rawQuery
of
Left
err
->
pure
$
SearchResult
$
SearchNoResult
(
T
.
pack
err
)
Right
q
->
do
$
(
logLocM
)
DEBUG
$
T
.
pack
"New search started with query = "
<>
(
getRawQuery
rawQuery
)
SearchResult
<$>
SearchResultDoc
<$>
map
(
toRow
nId
)
<$>
runDBQuery
(
searchInCorpus
nId
False
q
o
l
order
)
(
SearchQuery
rawQuery
SearchContact
)
->
case
parseQuery
rawQuery
of
Left
err
->
pure
$
SearchResult
$
SearchNoResult
(
T
.
pack
err
)
Right
q
->
runDBQuery
$
do
-- printDebug "isPairedWith" nId
aIds
<-
isPairedWith
nId
NodeAnnuaire
-- TODO if paired with several corpus
case
head
aIds
of
Nothing
->
pure
$
SearchResult
$
SearchNoResult
"[G.A.Search] pair corpus with an Annuaire"
Just
aId
->
SearchResult
<$>
SearchResultContact
<$>
map
(
toRow
aId
)
<$>
searchInCorpusWithContacts
nId
aId
q
o
l
order
(
SearchQuery
_q
SearchDocWithNgrams
)
->
panicTrace
"unimplemented"
searchEp
::
IsGargServer
env
err
m
=>
NodeId
->
SearchQuery
->
Maybe
Offset
->
Maybe
Limit
->
Maybe
OrderBy
->
m
SearchResult
searchEp
nId
(
SearchQuery
rawQuery
SearchDoc
)
o
l
order
=
case
parseQuery
rawQuery
of
Left
err
->
pure
$
SearchResult
$
SearchNoResult
(
T
.
pack
err
)
Right
q
->
do
$
(
logLocM
)
DEBUG
$
T
.
pack
"New search started with query = "
<>
getRawQuery
rawQuery
(
SearchResult
<$>
SearchResultDoc
)
.
map
(
toRow
nId
)
<$>
runDBQuery
(
searchInCorpus
nId
False
q
o
l
order
)
searchEp
nId
(
SearchQuery
rawQuery
SearchContact
)
o
l
order
=
case
parseQuery
rawQuery
of
Left
err
->
pure
$
SearchResult
$
SearchNoResult
(
T
.
pack
err
)
Right
q
->
runDBQuery
$
do
-- printDebug "isPairedWith" nId
aIds
<-
isPairedWith
nId
NodeAnnuaire
-- TODO if paired with several corpus
case
head
aIds
of
Nothing
->
pure
$
SearchResult
$
SearchNoResult
"[G.A.Search] pair corpus with an Annuaire"
Just
aId
->
(
SearchResult
<$>
SearchResultContact
)
.
map
(
toRow
aId
)
<$>
searchInCorpusWithContacts
nId
aId
q
o
l
order
searchEp
_nId
(
SearchQuery
_q
SearchDocWithNgrams
)
_o
_l
_order
=
panicTrace
"not implemented"
src/Gargantext/Database/Action/Search.hs
View file @
949c4225
...
@@ -14,7 +14,8 @@ Portability : POSIX
...
@@ -14,7 +14,8 @@ Portability : POSIX
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE LambdaCase #-}
module
Gargantext.Database.Action.Search
(
module
Gargantext.Database.Action.Search
(
searchInCorpus
queryToTsSearch
,
searchInCorpus
,
searchInCorpusWithContacts
,
searchInCorpusWithContacts
,
searchCountInCorpus
,
searchCountInCorpus
,
searchInCorpusWithNgrams
,
searchInCorpusWithNgrams
...
...
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