Commit 9144bad9 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[Commit Missing]

parents 5f59fdb2 e0dd2db8
Pipeline #6545 passed with stages
in 49 minutes and 6 seconds
......@@ -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
......
......@@ -29,7 +29,7 @@ source-repository-package
source-repository-package
type: git
location: https://gitlab.iscpif.fr/gargantext/opaleye-textsearch.git
tag: cb07b604bfb7a22aa21dd8918de5cb65c8a4bdf1
tag: 04b5c9044fef44393b66bffa258ca0b0f59c1087
source-repository-package
type: git
......
......@@ -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,
......
......@@ -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
......
......@@ -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
......
......@@ -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:
- .
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment