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
9144bad9
Commit
9144bad9
authored
Aug 26, 2024
by
Alexandre Delanoë
1
Browse files
Options
Browse Files
Download
Plain Diff
[Commit Missing]
parents
5f59fdb2
e0dd2db8
Pipeline
#6545
passed with stages
in 49 minutes and 6 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
15 deletions
+35
-15
update-project-dependencies
bin/update-project-dependencies
+4
-2
cabal.project
cabal.project
+1
-1
cabal.project.freeze
cabal.project.freeze
+1
-1
gargantext.cabal
gargantext.cabal
+1
-1
Search.hs
src/Gargantext/Database/Action/Search.hs
+27
-9
stack.yaml
stack.yaml
+1
-1
No files found.
bin/update-project-dependencies
View file @
9144bad9
...
...
@@ -18,8 +18,10 @@ fi
# with the `sha256sum` result calculated on the `cabal.project` and
# `cabal.project.freeze`. This ensures the files stay deterministic so that CI
# cache can kick in.
expected_cabal_project_hash
=
"c4b325f058cc2780e335db82712f50d0a4c316538518a7b7dfd1cd5d8e60a1e5"
expected_cabal_project_freeze_hash
=
"e0c16994182fb264e691ed8496bad0c2c0f4d237dc11e6525b5f990cb4edf6fe"
expected_cabal_project_hash
=
"9c487a789f77d9a96b4ac6a4b6268a075a72b8a391d987ba12194a46d96f6ee8"
expected_cabal_project_freeze_hash
=
"50f3ccea242400c48bd9cec7286bd07c8223c87c043e09576dd5fef0949f982a"
cabal
--store-dir
=
$STORE_DIR
v2-build
--dry-run
cabal2stack
--system-ghc
--allow-newer
--resolver
lts-21.17
--resolver-file
devops/stack/lts-21.17.yaml
-o
stack.yaml
...
...
cabal.project
View file @
9144bad9
...
...
@@ -29,7 +29,7 @@ source-repository-package
source
-
repository
-
package
type
:
git
location
:
https
://
gitlab
.
iscpif
.
fr
/
gargantext
/
opaleye
-
textsearch
.
git
tag
:
cb07b604bfb7a22aa21dd8918de5cb65c8a4bdf1
tag
:
04
b5c9044fef44393b66bffa258ca0b0f59c1087
source
-
repository
-
package
type
:
git
...
...
cabal.project.freeze
View file @
9144bad9
...
...
@@ -393,7 +393,7 @@ constraints: any.Cabal ==3.8.1.0,
any.old-locale ==1.0.0.7,
any.old-time ==1.1.0.3,
any.opaleye ==0.9.6.1,
any.opaleye-textsearch ==0.
1
.0.0,
any.opaleye-textsearch ==0.
2
.0.0,
any.openalex ==0.1.0.0,
any.optics-core ==0.4.1.1,
optics-core -explicit-generic-labels,
...
...
gargantext.cabal
View file @
9144bad9
...
...
@@ -620,7 +620,7 @@ library
, network >= 3.1.4.0
, network-uri ^>= 2.6.4.1
, opaleye ^>= 0.9.6.1
, opaleye-textsearch >= 0.
1
.0.0
, opaleye-textsearch >= 0.
2
.0.0
, openalex
, pandoc ^>= 2.14.0.3
, parallel ^>= 3.2.2.0
...
...
src/Gargantext/Database/Action/Search.hs
View file @
9144bad9
...
...
@@ -61,7 +61,9 @@ import Opaleye.TextSearch
--
queryToTsSearch
::
API
.
Query
->
Field
SqlTSQuery
queryToTsSearch
q
=
sqlToTSQuery
$
T
.
unpack
$
API
.
interpretQuery
q
transformAST
queryToTsSearch
q
=
let
(
dictionary
,
transformed
)
=
API
.
interpretQuery
q
transformAST
in
sqlToTSQuery
dictionary
(
T
.
unpack
transformed
)
where
-- It's important to understand how things work under the hood: When we perform
...
...
@@ -97,29 +99,45 @@ queryToTsSearch q = sqlToTSQuery $ T.unpack $ API.interpretQuery q transformAST
API
.
QT_partial_match
(
Term
term
)
->
stem
EN
GargPorterAlgorithm
term
<>
":*"
transformAST
::
BoolExpr
[
API
.
QueryTerm
]
->
T
.
Text
-- Transforms the input query terms and returns the full SQL query to feed Postgres AND
-- the dictionary to use, see: https://www.postgresql.org/docs/current/textsearch-dictionaries.html
-- In a nutshell, if we have a partial match operator in our query, we use the \"simple\" dictionary
-- under the hood, which won't filter stop words, which are sometimes useful, see issue #265.
transformAST
::
BoolExpr
[
API
.
QueryTerm
]
->
(
Maybe
Dictionary
,
T
.
Text
)
transformAST
ast
=
case
ast
of
BAnd
sub1
sub2
->
" ("
<>
transformAST
sub1
<>
" & "
<>
transformAST
sub2
<>
") "
->
let
(
d1
,
sub1Expr
)
=
transformAST
sub1
(
d2
,
sub2Expr
)
=
transformAST
sub2
in
(
d1
<|>
d2
,
" ("
<>
sub1Expr
<>
" & "
<>
sub2Expr
<>
") "
)
BOr
sub1
sub2
->
" ("
<>
transformAST
sub1
<>
" | "
<>
transformAST
sub2
<>
") "
->
let
(
d1
,
sub1Expr
)
=
transformAST
sub1
(
d2
,
sub2Expr
)
=
transformAST
sub2
in
(
d1
<|>
d2
,
" ("
<>
sub1Expr
<>
" | "
<>
sub2Expr
<>
") "
)
BNot
(
BConst
(
Negative
term
))
->
transformAST
(
BConst
(
Positive
term
))
-- double negation
BNot
sub
->
"!"
<>
transformAST
sub
->
second
(
\
e
->
"!"
<>
e
)
$
transformAST
sub
-- BTrue cannot happen is the query parser doesn't support parsing 'TRUE' alone.
BTrue
->
T
.
empty
->
(
Nothing
,
T
.
empty
)
-- BTrue cannot happen is the query parser doesn't support parsing 'FALSE' alone.
BFalse
->
T
.
empty
->
(
Nothing
,
T
.
empty
)
BConst
(
Positive
queryTerms
)
->
renderQueryTerms
queryTerms
->
(
pickDictionary
queryTerms
,
renderQueryTerms
queryTerms
)
-- We can handle negatives via `ANDNOT` with itself.
BConst
(
Negative
queryTerms
)
->
"!"
<>
renderQueryTerms
queryTerms
->
(
pickDictionary
queryTerms
,
"!"
<>
renderQueryTerms
queryTerms
)
pickDictionary
::
[
API
.
QueryTerm
]
->
Maybe
Dictionary
pickDictionary
qs
=
if
any
isPartialMatch
qs
then
Just
(
Dictionary
"simple"
)
else
Nothing
where
isPartialMatch
::
API
.
QueryTerm
->
Bool
isPartialMatch
=
\
case
API
.
QT_partial_match
{}
->
True
_
->
False
------------------------------------------------------------------------
searchDocInDatabase
::
HasDBid
NodeType
=>
ParentId
...
...
stack.yaml
View file @
9144bad9
...
...
@@ -182,7 +182,7 @@
git
:
"
https://gitlab.iscpif.fr/gargantext/iso639.git"
subdirs
:
-
.
-
commit
:
cb07b604bfb7a22aa21dd8918de5cb65c8a4bdf1
-
commit
:
04b5c9044fef44393b66bffa258ca0b0f59c1087
git
:
"
https://gitlab.iscpif.fr/gargantext/opaleye-textsearch.git"
subdirs
:
-
.
...
...
Przemyslaw Kaminski
@cgenie
mentioned in commit
5660aec0
·
Oct 08, 2024
mentioned in commit
5660aec0
mentioned in commit 5660aec07ec5a0a0a5468f440092c1a8f57a864e
Toggle commit list
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