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
195
Issues
195
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
092d482b
Commit
092d482b
authored
Oct 28, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '145-graphExplorerSearch' into 145-dev-graph-explorer-search-tfidf
parents
3b163685
b7c7b416
Pipeline
#3330
failed with stage
in 47 minutes and 42 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
5 deletions
+24
-5
Search.hs
src/Gargantext/API/Search.hs
+8
-5
Search.hs
src/Gargantext/Database/Action/Search.hs
+16
-0
No files found.
src/Gargantext/API/Search.hs
View file @
092d482b
...
...
@@ -18,6 +18,7 @@ module Gargantext.API.Search
where
import
Data.Aeson
hiding
(
defaultTaggedObject
)
import
Data.List
(
concat
)
import
Data.Maybe
(
fromMaybe
)
import
Data.Swagger
hiding
(
fieldLabelModifier
,
Contact
)
import
Data.Text
(
Text
)
...
...
@@ -55,7 +56,7 @@ api :: NodeId -> GargServer (API SearchResult)
api
nId
(
SearchQuery
q
SearchDoc
)
o
l
order
=
SearchResult
<$>
SearchResultDoc
<$>
map
(
toRow
nId
)
<$>
searchInCorpus
nId
False
q
o
l
order
<$>
searchInCorpus
nId
False
(
concat
q
)
o
l
order
api
nId
(
SearchQuery
q
SearchContact
)
o
l
order
=
do
printDebug
"isPairedWith"
nId
...
...
@@ -67,13 +68,15 @@ api nId (SearchQuery q SearchContact) o l order = do
Just
aId
->
SearchResult
<$>
SearchResultContact
<$>
map
(
toRow
aId
)
<$>
searchInCorpusWithContacts
nId
aId
q
o
l
order
<$>
searchInCorpusWithContacts
nId
aId
(
concat
q
)
o
l
order
api
nId
(
SearchQuery
q
SearchDocWithNgrams
)
o
l
order
=
undefined
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-- | Main Types
-----------------------------------------------------------------------
data
SearchType
=
SearchDoc
|
SearchContact
data
SearchType
=
SearchDoc
|
SearchContact
|
SearchDocWithNgrams
deriving
(
Generic
)
instance
FromJSON
SearchType
where
parseJSON
=
genericParseJSON
(
defaultOptions
{
sumEncoding
=
ObjectWithSingleField
})
...
...
@@ -85,7 +88,7 @@ instance Arbitrary SearchType where
-----------------------------------------------------------------------
data
SearchQuery
=
SearchQuery
{
query
::
!
[
Text
]
SearchQuery
{
query
::
!
[
[
Text
]
]
,
expected
::
!
SearchType
}
deriving
(
Generic
)
...
...
@@ -100,7 +103,7 @@ instance ToSchema SearchQuery
-}
instance
Arbitrary
SearchQuery
where
arbitrary
=
elements
[
SearchQuery
[
"electrodes"
]
SearchDoc
]
arbitrary
=
elements
[
SearchQuery
[
[
"electrodes"
]
]
SearchDoc
]
-- arbitrary = elements [SearchQuery "electrodes" 1 ] --SearchDoc]
-----------------------------------------------------------------------
data
SearchResult
=
...
...
src/Gargantext/Database/Action/Search.hs
View file @
092d482b
...
...
@@ -27,6 +27,7 @@ import Gargantext.Database.Query.Join (leftJoin5)
import
Gargantext.Database.Query.Table.Node
import
Gargantext.Database.Query.Table.Context
import
Gargantext.Database.Query.Table.NodeContext
import
Gargantext.Database.Schema.Ngrams
(
NgramsType
(
..
))
import
Gargantext.Database.Query.Table.NodeContext_NodeContext
import
Gargantext.Database.Schema.Node
import
Gargantext.Database.Schema.Context
...
...
@@ -51,6 +52,21 @@ searchDocInDatabase p t = runOpaQuery (queryDocInDatabase p t)
restrict
-<
(
_ns_typename
row
)
.==
(
sqlInt4
$
toDBid
NodeDocument
)
returnA
-<
(
_ns_id
row
,
_ns_hyperdata
row
)
------------------------------------------------------------------------
searchInCorpusWithNgrams
::
HasDBid
NodeType
=>
CorpusId
->
ListId
->
IsTrash
->
NgramsType
->
[[
Text
]]
->
Maybe
Offset
->
Maybe
Limit
->
Maybe
OrderBy
->
Cmd
err
[
FacetDoc
]
searchInCorpusWithNgrams
cId
lId
t
ngt
q
o
l
order
=
undefined
------------------------------------------------------------------------
-- | todo add limit and offset and order
searchInCorpus
::
HasDBid
NodeType
...
...
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