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
199
Issues
199
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
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
e5ad8435
Commit
e5ad8435
authored
Dec 13, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SearchIn] Corpus API route : corpus/{id}/search
parent
34fbf078
Pipeline
#65
failed with stage
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
2 deletions
+32
-2
Node.hs
src/Gargantext/API/Node.hs
+9
-0
Search.hs
src/Gargantext/API/Search.hs
+22
-0
Flow.hs
src/Gargantext/Database/Flow.hs
+1
-2
No files found.
src/Gargantext/API/Node.hs
View file @
e5ad8435
...
@@ -58,6 +58,7 @@ import qualified Gargantext.Database.Node.Update as U (update, Update(..))
...
@@ -58,6 +58,7 @@ import qualified Gargantext.Database.Node.Update as U (update, Update(..))
import
Gargantext.Database.Facet
(
FacetDoc
,
runViewDocuments'
,
OrderBy
(
..
),
FacetChart
,
runViewAuthorsDoc
)
import
Gargantext.Database.Facet
(
FacetDoc
,
runViewDocuments'
,
OrderBy
(
..
),
FacetChart
,
runViewAuthorsDoc
)
import
Gargantext.Database.Tree
(
treeDB
,
HasTreeError
(
..
),
TreeError
(
..
))
import
Gargantext.Database.Tree
(
treeDB
,
HasTreeError
(
..
),
TreeError
(
..
))
import
Gargantext.Database.Schema.NodeNode
(
nodesToFavorite
,
nodesToTrash
)
import
Gargantext.Database.Schema.NodeNode
(
nodesToFavorite
,
nodesToTrash
)
import
Gargantext.API.Search
(
SearchAPI
,
searchIn
,
SearchInQuery
)
-- Graph
-- Graph
--import Gargantext.Text.Flow
--import Gargantext.Text.Flow
import
Gargantext.Viz.Graph
hiding
(
Node
)
-- (Graph(_graph_metadata),LegendField(..), GraphMetadata(..),readGraphFromJson,defaultGraph)
import
Gargantext.Viz.Graph
hiding
(
Node
)
-- (Graph(_graph_metadata),LegendField(..), GraphMetadata(..),readGraphFromJson,defaultGraph)
...
@@ -113,6 +114,12 @@ type NodeAPI a = Get '[JSON] (Node a)
...
@@ -113,6 +114,12 @@ type NodeAPI a = Get '[JSON] (Node a)
:<|>
"chart"
:>
ChartApi
:<|>
"chart"
:>
ChartApi
:<|>
"favorites"
:>
FavApi
:<|>
"favorites"
:>
FavApi
:<|>
"documents"
:>
DocsApi
:<|>
"documents"
:>
DocsApi
:<|>
"search"
:>
Summary
"Node Search"
:>
ReqBody
'[
J
SON
]
SearchInQuery
:>
QueryParam
"offset"
Int
:>
QueryParam
"limit"
Int
:>
QueryParam
"order"
OrderBy
:>
SearchAPI
type
RenameApi
=
Summary
" RenameNode Node"
type
RenameApi
=
Summary
" RenameNode Node"
:>
ReqBody
'[
J
SON
]
RenameNode
:>
ReqBody
'[
J
SON
]
RenameNode
...
@@ -147,6 +154,8 @@ nodeAPI conn p id
...
@@ -147,6 +154,8 @@ nodeAPI conn p id
:<|>
getChart
conn
id
:<|>
getChart
conn
id
:<|>
favApi
conn
id
:<|>
favApi
conn
id
:<|>
delDocs
conn
id
:<|>
delDocs
conn
id
:<|>
searchIn
conn
id
-- Annuaire
-- Annuaire
-- :<|> upload
-- :<|> upload
-- :<|> query
-- :<|> query
...
...
src/Gargantext/API/Search.hs
View file @
e5ad8435
...
@@ -42,6 +42,8 @@ import Gargantext.Database.TextSearch
...
@@ -42,6 +42,8 @@ import Gargantext.Database.TextSearch
import
Gargantext.Database.Facet
import
Gargantext.Database.Facet
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-- | SearchIn [NodesId] if empty then global search
-- TODO [Int]
data
SearchQuery
=
SearchQuery
{
sq_query
::
[
Text
]
data
SearchQuery
=
SearchQuery
{
sq_query
::
[
Text
]
,
sq_corpus_id
::
Int
,
sq_corpus_id
::
Int
}
deriving
(
Generic
)
}
deriving
(
Generic
)
...
@@ -54,6 +56,20 @@ instance ToSchema SearchQuery where
...
@@ -54,6 +56,20 @@ instance ToSchema SearchQuery where
instance
Arbitrary
SearchQuery
where
instance
Arbitrary
SearchQuery
where
arbitrary
=
elements
[
SearchQuery
[
"electrodes"
]
472764
]
arbitrary
=
elements
[
SearchQuery
[
"electrodes"
]
472764
]
--
data
SearchInQuery
=
SearchInQuery
{
siq_query
::
[
Text
]
}
deriving
(
Generic
)
$
(
deriveJSON
(
unPrefix
"siq_"
)
''
S
earchInQuery
)
instance
ToSchema
SearchInQuery
where
declareNamedSchema
=
genericDeclareNamedSchema
defaultSchemaOptions
{
fieldLabelModifier
=
\
fieldLabel
->
drop
4
fieldLabel
}
instance
Arbitrary
SearchInQuery
where
arbitrary
=
SearchInQuery
<$>
arbitrary
-----------------------------------------------------------------------
-----------------------------------------------------------------------
data
SearchResults
=
SearchResults
{
srs_results
::
[
FacetPaired
Int
UTCTime
HyperdataDocument
Int
[
Pair
Int
Text
]]}
data
SearchResults
=
SearchResults
{
srs_results
::
[
FacetPaired
Int
UTCTime
HyperdataDocument
Int
[
Pair
Int
Text
]]}
...
@@ -75,3 +91,9 @@ type SearchAPI = Post '[JSON] SearchResults
...
@@ -75,3 +91,9 @@ type SearchAPI = Post '[JSON] SearchResults
search
::
Connection
->
SearchQuery
->
Maybe
Offset
->
Maybe
Limit
->
Maybe
OrderBy
->
Handler
SearchResults
search
::
Connection
->
SearchQuery
->
Maybe
Offset
->
Maybe
Limit
->
Maybe
OrderBy
->
Handler
SearchResults
search
c
(
SearchQuery
q
pId
)
o
l
order
=
search
c
(
SearchQuery
q
pId
)
o
l
order
=
liftIO
$
SearchResults
<$>
searchInCorpusWithContacts
c
pId
q
o
l
order
liftIO
$
SearchResults
<$>
searchInCorpusWithContacts
c
pId
q
o
l
order
searchIn
::
Connection
->
NodeId
->
SearchInQuery
->
Maybe
Offset
->
Maybe
Limit
->
Maybe
OrderBy
->
Handler
SearchResults
searchIn
c
nId
(
SearchInQuery
q
)
o
l
order
=
liftIO
$
SearchResults
<$>
searchInCorpusWithContacts
c
nId
q
o
l
order
src/Gargantext/Database/Flow.hs
View file @
e5ad8435
...
@@ -151,7 +151,7 @@ subFlowCorpus username cName = do
...
@@ -151,7 +151,7 @@ subFlowCorpus username cName = do
True
->
panic
"Error: more than 1 userNode / user"
True
->
panic
"Error: more than 1 userNode / user"
False
->
pure
rootId'
False
->
pure
rootId'
let
rootId
=
maybe
(
panic
"error rootId"
)
identity
(
head
rootId''
)
let
rootId
=
maybe
(
panic
"error rootId"
)
identity
(
head
rootId''
)
--{-
corpusId''
<-
if
username
==
userMaster
corpusId''
<-
if
username
==
userMaster
then
do
then
do
ns
<-
runCmd'
$
getCorporaWithParentId'
rootId
ns
<-
runCmd'
$
getCorporaWithParentId'
rootId
...
@@ -159,7 +159,6 @@ subFlowCorpus username cName = do
...
@@ -159,7 +159,6 @@ subFlowCorpus username cName = do
else
else
pure
[]
pure
[]
--}
corpusId'
<-
if
corpusId''
/=
[]
corpusId'
<-
if
corpusId''
/=
[]
then
pure
corpusId''
then
pure
corpusId''
else
runCmd'
$
mkCorpus
(
Just
cName
)
Nothing
rootId
userId
else
runCmd'
$
mkCorpus
(
Just
cName
)
Nothing
rootId
userId
...
...
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