[ngrams] search with plainto_tsquery is more permissive

parent ff93628e
...@@ -216,6 +216,9 @@ getContextNgrams contextId listId = do ...@@ -216,6 +216,9 @@ getContextNgrams contextId listId = do
-- and list_id that match the search tsvector. -- and list_id that match the search tsvector.
-- NOTE This is poor man's tokenization that is used as a hint for the -- NOTE This is poor man's tokenization that is used as a hint for the
-- frontend highlighter. -- frontend highlighter.
-- NOTE We prefer `plainto_tsquery` over `phraseto_tsquery` as it is
-- more permissive (i.e. ignores word ordering). See
-- https://www.peterullrich.com/complete-guide-to-full-text-search-with-postgres-and-ecto
getContextNgramsMatchingFTS :: HasNodeError err getContextNgramsMatchingFTS :: HasNodeError err
=> NodeId => NodeId
-> NodeId -> NodeId
...@@ -232,7 +235,7 @@ getContextNgramsMatchingFTS contextId listId = do ...@@ -232,7 +235,7 @@ getContextNgramsMatchingFTS contextId listId = do
CROSS JOIN contexts CROSS JOIN contexts
WHERE contexts.id = ? WHERE contexts.id = ?
AND node_ngrams.node_id = ? AND node_ngrams.node_id = ?
AND contexts.search @@ phraseto_tsquery(ngrams.terms) |] AND contexts.search @@ plainto_tsquery(ngrams.terms) |]
------------------------------------------------------------------------ ------------------------------------------------------------------------
insertNodeContext :: [NodeContext] -> Cmd err Int insertNodeContext :: [NodeContext] -> Cmd err Int
insertNodeContext ns = mkCmd $ \conn -> fromIntegral <$> (runInsert_ conn insertNodeContext ns = mkCmd $ \conn -> fromIntegral <$> (runInsert_ conn
......
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