Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
142
Issues
142
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
purescript-gargantext
Commits
9bc7e9c1
Commit
9bc7e9c1
authored
Apr 13, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[HAL] fixes to search query
parent
89aa1f16
Pipeline
#2712
failed with stage
in 0 seconds
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
+17
-9
SearchField.purs
...omponents/Forest/Tree/Node/Action/Search/SearchField.purs
+17
-9
No files found.
src/Gargantext/Components/Forest/Tree/Node/Action/Search/SearchField.purs
View file @
9bc7e9c1
...
...
@@ -571,7 +571,7 @@ triggerSearch { onSearch, errors, session, selection, search } =
case search.node_id of
Nothing -> liftEffect $ here.log "[triggerSearch] node_id is Nothing, don't know what to do"
Just id -> do
liftEffect $ here.log2 "[triggerSearch] search
"
search
liftEffect $ here.log2 "[triggerSearch] search
Query" $ searchQuery selection
search
eTask <- performSearch session id $ searchQuery selection search
handleRESTError errors eTask $ \task -> liftEffect $ do
here.log2 "[triggerSearch] task" task
...
...
@@ -623,25 +623,33 @@ searchQuery selection { databases, datafield, lang, term, node_id } =
queryHAL :: String -> Maybe (Set.Set IMT_org) -> Maybe Lang -> Array String -> String
queryHAL term mIMTOrgs lang years =
"(" <> langPrefix <> "_title_t:" <> termEscaped <>
" OR " <> langPrefix <> "_abstract_t:\"" <> termEscaped <> "\")" <>
structQuery <> yearQuery
joinWith " AND " $ filterOutEmptyString [ titleAbstract
, structQuery
, yearQuery ]
where
-- this uses solr query syntax
-- https://yonik.com/solr/query-syntax/
titleAbstract = case term of
"" -> ""
_ -> "(" <> langPrefix <> "_title_t:" <> termMulti <>
" OR " <> langPrefix <> "_abstract_t:" <> termMulti <> ")"
langPrefix = case lang of
Just FR -> "fr"
_ -> "en"
-- TODO: Escape double quotes
termEscaped = "\"" <> (replaceAll (Pattern "\"") (Replacement "\\\"") term) <> "\""
--termEscaped = "\"" <> (replaceAll (Pattern "\"") (Replacement "\\\"") term) <> "\""
termEscaped = "\"" <> term <> "\""
termMulti = "(" <> term <> ")"
structQuery = case mIMTOrgs of
Nothing -> ""
Just imtOrgs -> if Set.isEmpty imtOrgs then
""
else
" AND (" <> (structIds imtOrgs) <> ")"
yearQuery' = joinWith " AND " $ (\year -> "producedDateY_i:" <> year) <$> years
yearQuery = if yearQuery' == "" then "" else " AND " <> yearQuery'
" (" <> (structIds imtOrgs) <> ")"
yearQuery = joinWith " AND " $ (\year -> "producedDateY_i:" <> year) <$> years
joinFunc :: IMT_org -> String
joinFunc All_IMT = ""
joinFunc (IMT_org { school_id }) = "structId_i:" <> school_id
structIds :: Set.Set IMT_org -> String
structIds imtOrgs = joinWith " OR " $ joinFunc <$> Set.toUnfoldable imtOrgs
structIds imtOrgs = joinWith " OR " $ filterOutEmptyString $ joinFunc <$> Set.toUnfoldable imtOrgs
filterOutEmptyString = A.filter (_ /= "")
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