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
150
Issues
150
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
7e77066f
Unverified
Commit
7e77066f
authored
Jun 27, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update the search API
parent
5f31a345
Pipeline
#497
failed with stage
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
53 deletions
+46
-53
API.hs
src/Gargantext/API.hs
+3
-9
Node.hs
src/Gargantext/API/Node.hs
+4
-10
Search.hs
src/Gargantext/API/Search.hs
+39
-34
No files found.
src/Gargantext/API.hs
View file @
7e77066f
...
@@ -73,11 +73,10 @@ import Gargantext.API.Count ( CountAPI, count, Query)
...
@@ -73,11 +73,10 @@ import Gargantext.API.Count ( CountAPI, count, Query)
import
Gargantext.API.FrontEnd
(
FrontEndAPI
,
frontEndServer
)
import
Gargantext.API.FrontEnd
(
FrontEndAPI
,
frontEndServer
)
import
Gargantext.API.Ngrams
(
HasRepo
(
..
),
HasRepoSaver
(
..
),
saveRepo
,
TableNgramsApi
,
apiNgramsTableDoc
)
import
Gargantext.API.Ngrams
(
HasRepo
(
..
),
HasRepoSaver
(
..
),
saveRepo
,
TableNgramsApi
,
apiNgramsTableDoc
)
import
Gargantext.API.Node
import
Gargantext.API.Node
import
Gargantext.API.Search
(
SearchAPI
,
search
,
SearchQuery
)
import
Gargantext.API.Search
(
SearchPairsAPI
,
searchPairs
)
import
Gargantext.API.Types
import
Gargantext.API.Types
import
qualified
Gargantext.API.Corpus.New
as
New
import
qualified
Gargantext.API.Corpus.New
as
New
import
Gargantext.Core.Types
(
HasInvalidError
(
..
))
import
Gargantext.Core.Types
(
HasInvalidError
(
..
))
import
Gargantext.Database.Facet
import
Gargantext.Database.Schema.Node
(
HasNodeError
(
..
),
NodeError
)
import
Gargantext.Database.Schema.Node
(
HasNodeError
(
..
),
NodeError
)
import
Gargantext.Database.Tree
(
HasTreeError
(
..
),
TreeError
)
import
Gargantext.Database.Tree
(
HasTreeError
(
..
),
TreeError
)
import
Gargantext.Database.Types.Node
import
Gargantext.Database.Types.Node
...
@@ -263,12 +262,7 @@ type GargAPI' =
...
@@ -263,12 +262,7 @@ type GargAPI' =
:>
ReqBody
'[
J
SON
]
Query
:>
CountAPI
:>
ReqBody
'[
J
SON
]
Query
:>
CountAPI
-- Corpus endpoint --> TODO rename s/search/filter/g
-- Corpus endpoint --> TODO rename s/search/filter/g
:<|>
"search"
:>
Summary
"Search endpoint"
:<|>
"search"
:>
Capture
"corpus"
NodeId
:>
SearchPairsAPI
:>
ReqBody
'[
J
SON
]
SearchQuery
:>
QueryParam
"offset"
Int
:>
QueryParam
"limit"
Int
:>
QueryParam
"order"
OrderBy
:>
SearchAPI
-- TODO move to NodeAPI?
-- TODO move to NodeAPI?
:<|>
"graph"
:>
Summary
"Graph endpoint"
:<|>
"graph"
:>
Summary
"Graph endpoint"
...
@@ -320,7 +314,7 @@ serverGargAPI -- orchestrator
...
@@ -320,7 +314,7 @@ serverGargAPI -- orchestrator
:<|>
apiNgramsTableDoc
:<|>
apiNgramsTableDoc
:<|>
nodesAPI
:<|>
nodesAPI
:<|>
count
-- TODO: undefined
:<|>
count
-- TODO: undefined
:<|>
search
:<|>
search
Pairs
-- TODO: move elsewhere
:<|>
graphAPI
-- TODO: mock
:<|>
graphAPI
-- TODO: mock
:<|>
treeAPI
:<|>
treeAPI
:<|>
New
.
api
:<|>
New
.
api
...
...
src/Gargantext/API/Node.hs
View file @
7e77066f
...
@@ -51,7 +51,7 @@ import GHC.Generics (Generic)
...
@@ -51,7 +51,7 @@ import GHC.Generics (Generic)
import
Gargantext.API.Metrics
import
Gargantext.API.Metrics
import
Gargantext.API.Ngrams
(
TabType
(
..
),
TableNgramsApi
,
apiNgramsTableCorpus
,
QueryParamR
,
TODO
)
import
Gargantext.API.Ngrams
(
TabType
(
..
),
TableNgramsApi
,
apiNgramsTableCorpus
,
QueryParamR
,
TODO
)
import
Gargantext.API.Ngrams.NTree
(
MyTree
)
import
Gargantext.API.Ngrams.NTree
(
MyTree
)
import
Gargantext.API.Search
(
SearchAPI
,
searchIn
,
SearchInQuery
)
import
Gargantext.API.Search
(
SearchDocsAPI
,
searchDocs
)
import
Gargantext.API.Types
import
Gargantext.API.Types
import
Gargantext.Core.Types
(
Offset
,
Limit
)
import
Gargantext.Core.Types
(
Offset
,
Limit
)
import
Gargantext.Core.Types.Main
(
Tree
,
NodeTree
,
ListType
)
import
Gargantext.Core.Types.Main
(
Tree
,
NodeTree
,
ListType
)
...
@@ -130,15 +130,10 @@ type NodeAPI a = Get '[JSON] (Node a)
...
@@ -130,15 +130,10 @@ type NodeAPI a = Get '[JSON] (Node a)
:<|>
"table"
:>
TableApi
:<|>
"table"
:>
TableApi
:<|>
"ngrams"
:>
TableNgramsApi
:<|>
"ngrams"
:>
TableNgramsApi
:<|>
"pairing"
:>
PairingApi
:<|>
"pairing"
:>
PairingApi
:<|>
"favorites"
:>
FavApi
:<|>
"favorites"
:>
FavApi
:<|>
"documents"
:>
DocsApi
:<|>
"documents"
:>
DocsApi
:<|>
"search"
:>
Summary
"Node Search"
:<|>
"search"
:>
SearchDocsAPI
:>
ReqBody
'[
J
SON
]
SearchInQuery
:>
QueryParam
"offset"
Int
:>
QueryParam
"limit"
Int
:>
QueryParam
"order"
OrderBy
:>
SearchAPI
-- VIZ
-- VIZ
:<|>
"metrics"
:>
ScatterAPI
:<|>
"metrics"
:>
ScatterAPI
...
@@ -182,8 +177,7 @@ nodeAPI p uId id
...
@@ -182,8 +177,7 @@ nodeAPI p uId id
:<|>
favApi
id
:<|>
favApi
id
:<|>
delDocs
id
:<|>
delDocs
id
:<|>
searchIn
id
:<|>
searchDocs
id
:<|>
getScatter
id
:<|>
getScatter
id
:<|>
getChart
id
:<|>
getChart
id
:<|>
getPie
id
:<|>
getPie
id
...
...
src/Gargantext/API/Search.hs
View file @
7e77066f
...
@@ -33,54 +33,50 @@ import Servant
...
@@ -33,54 +33,50 @@ import Servant
import
Test.QuickCheck.Arbitrary
import
Test.QuickCheck.Arbitrary
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck
(
elements
)
-- import Control.Applicative ((<*>))
-- import Control.Applicative ((<*>))
import
Gargantext.API.Types
(
GargServer
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Core.Utils.Prefix
(
unPrefix
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
)
import
Gargantext.Core.Types.Main
(
Offset
,
Limit
)
import
Gargantext.Database.Types.Node
import
Gargantext.Database.Types.Node
import
Gargantext.Database.TextSearch
import
Gargantext.Database.TextSearch
import
Gargantext.Database.Facet
import
Gargantext.Database.Facet
import
Gargantext.Database.Utils
(
Cmd
)
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-- | SearchIn [NodesId] if empty then global search
data
SearchQuery
=
SearchQuery
-- TODO [Int]
{
sq_query
::
[
Text
]
data
SearchQuery
=
SearchQuery
{
sq_query
::
[
Text
]
}
deriving
(
Generic
)
,
sq_corpus_id
::
NodeId
}
deriving
(
Generic
)
$
(
deriveJSON
(
unPrefix
"sq_"
)
''
S
earchQuery
)
$
(
deriveJSON
(
unPrefix
"sq_"
)
''
S
earchQuery
)
instance
ToSchema
SearchQuery
where
instance
ToSchema
SearchQuery
where
declareNamedSchema
=
declareNamedSchema
=
genericDeclareNamedSchema
genericDeclareNamedSchema
defaultSchemaOptions
{
fieldLabelModifier
=
\
fieldLabel
->
drop
3
fieldLabel
}
defaultSchemaOptions
{
fieldLabelModifier
=
drop
3
}
instance
Arbitrary
SearchQuery
where
instance
Arbitrary
SearchQuery
where
arbitrary
=
elements
[
SearchQuery
[
"electrodes"
]
472764
]
arbitrary
=
elements
[
SearchQuery
[
"electrodes"
]]
--
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
data
SearchDocResults
=
SearchDocResults
{
sdr_results
::
[
FacetDoc
]}
arbitrary
=
SearchInQuery
<$>
arbitrary
deriving
(
Generic
)
$
(
deriveJSON
(
unPrefix
"sdr_"
)
''
S
earchDocResults
)
instance
Arbitrary
SearchDocResults
where
arbitrary
=
SearchDocResults
<$>
arbitrary
-----------------------------------------------------------------------
instance
ToSchema
SearchDocResults
where
declareNamedSchema
=
genericDeclareNamedSchema
defaultSchemaOptions
{
fieldLabelModifier
=
drop
4
}
data
SearchResults
=
SearchResults'
{
srs_resultsP
::
[
FacetDoc
]}
data
SearchPairedResults
=
SearchPairedResults
{
spr_results
::
[
FacetPaired
Int
UTCTime
HyperdataDocument
Int
[
Pair
Int
Text
]]
}
|
SearchResults
{
srs_results
::
[
FacetPaired
Int
UTCTime
HyperdataDocument
Int
[
Pair
Int
Text
]]}
deriving
(
Generic
)
deriving
(
Generic
)
$
(
deriveJSON
(
unPrefix
"s
rs_"
)
''
S
earch
Results
)
$
(
deriveJSON
(
unPrefix
"s
pr_"
)
''
S
earchPaired
Results
)
instance
Arbitrary
SearchResults
where
instance
Arbitrary
Search
Paired
Results
where
arbitrary
=
SearchResults
<$>
arbitrary
arbitrary
=
Search
Paired
Results
<$>
arbitrary
instance
ToSchema
SearchResults
where
instance
ToSchema
Search
Paired
Results
where
declareNamedSchema
=
declareNamedSchema
=
genericDeclareNamedSchema
genericDeclareNamedSchema
defaultSchemaOptions
{
fieldLabelModifier
=
\
fieldLabel
->
drop
4
fieldLabel
}
defaultSchemaOptions
{
fieldLabelModifier
=
\
fieldLabel
->
drop
4
fieldLabel
}
...
@@ -88,16 +84,25 @@ instance ToSchema SearchResults where
...
@@ -88,16 +84,25 @@ instance ToSchema SearchResults where
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-- TODO-ACCESS: CanSearch? or is it part of CanGetNode
-- TODO-ACCESS: CanSearch? or is it part of CanGetNode
-- TODO-EVENTS: No event, this is a read-only query.
-- TODO-EVENTS: No event, this is a read-only query.
type
SearchAPI
=
Post
'[
J
SON
]
SearchResults
type
SearchAPI
results
=
Summary
"Search endpoint"
:>
ReqBody
'[
J
SON
]
SearchQuery
:>
QueryParam
"offset"
Int
:>
QueryParam
"limit"
Int
:>
QueryParam
"order"
OrderBy
:>
Post
'[
J
SON
]
results
type
SearchDocsAPI
=
SearchAPI
SearchDocResults
type
SearchPairsAPI
=
SearchAPI
SearchPairedResults
-----------------------------------------------------------------------
-----------------------------------------------------------------------
search
::
SearchQuery
->
Maybe
Offset
->
Maybe
Limit
->
Maybe
OrderBy
->
Cmd
err
SearchResults
search
Pairs
::
NodeId
->
GargServer
SearchPairsAPI
search
(
SearchQuery
q
pId
)
o
l
order
=
search
Pairs
pId
(
SearchQuery
q
)
o
l
order
=
SearchResults
<$>
searchInCorpusWithContacts
pId
q
o
l
order
Search
Paired
Results
<$>
searchInCorpusWithContacts
pId
q
o
l
order
search
In
::
NodeId
->
SearchInQuery
->
Maybe
Offset
->
Maybe
Limit
->
Maybe
OrderBy
->
Cmd
err
SearchResults
search
Docs
::
NodeId
->
GargServer
SearchDocsAPI
search
In
nId
(
SearchInQuery
q
)
o
l
order
=
search
Docs
nId
(
SearchQuery
q
)
o
l
order
=
Search
Results'
<$>
searchInCorpus
nId
q
o
l
order
Search
DocResults
<$>
searchInCorpus
nId
q
o
l
order
--SearchResults <$> searchInCorpusWithContacts nId q o l order
--SearchResults <$> searchInCorpusWithContacts nId q o l order
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