| Copyright | (c) Gargantext 2024- |
|---|---|
| License | AGPL-3.0-or-later |
| Maintainer | gargantext@iscpif.fr |
| Stability | 0.1.0.0 |
| Portability | POSIX |
| Safe Haskell | Safe-Inferred |
| Language | GHC2021 |
Opaleye.TextSearch
Description
Synopsis
- data SqlTSQuery
- data SqlTSVector
- (@@) :: Field SqlTSVector -> Field SqlTSQuery -> Field SqlBool
- pgTSVector :: Field SqlText -> Field SqlTSVector
- pgTSQuery :: Field SqlText -> Field SqlTSQuery
- sqlTSQuery :: String -> Field SqlTSQuery
- sqlPlainToTSQuery :: String -> Field SqlTSQuery
- sqlToTSQuery :: String -> Field SqlTSQuery
- to_pgTSQuery :: String -> Field SqlTSQuery
- plainto_pgTSQuery :: String -> Field SqlTSQuery
How to use
Example:
data MyEntity id text search =
MyEntity { _id :: id
, _text :: text
, _search :: search }
deriving (Show, Generic)
$(makeAdaptorAndInstance "pMyEntity" ''MyEntity)
type MyEntityRead =
MyEntity
(Field SqlInt4 )
(Field SqlText )
(Field SqlTSVector )
type MyEntityWrite =
MyEntity
(Maybe (Field SqlInt4 ))
(Field SqlText )
(Field SqlTSVector )
myEntityTable :: Table MyEntityWrite MyEntityRead
myEntityTable = Table "my_entity" ( pMyEntity
MyEntity { _id = optionalTableField "id"
, _text = requiredTableField "text"
, _search = optionalTableField "search_vector"
}
)
myQuery :: Text -> Select (Column SqlInt4, Column SqlText)
myQuery q = proc () -> do
row <- myEntityTable -< ()
restrict -< (_search row) @@ (sqlPlainToTSQuery (unpack q))
returnA -< (_id row, _text row)
runSelect conn (myQuery "hello world")
Types
data SqlTSQuery Source #
Instances
| IsSqlType SqlTSQuery Source # | |
Defined in Opaleye.TextSearch.Internal.Types Methods showSqlType :: proxy SqlTSQuery -> String # | |
data SqlTSVector Source #
Functions and operators
(@@) :: Field SqlTSVector -> Field SqlTSQuery -> Field SqlBool infix 4 Source #
PostgreSQL match operator (checks if tsvector matches given tsquery).
pgTSVector :: Field SqlText -> Field SqlTSVector Source #
PostgreSQL tsvector coercion from text.
sqlTSQuery :: String -> Field SqlTSQuery Source #
Coerce given String to tsquery.
Various parsing queries
For to_tsquery, plainto_tsquery, etc. functions, see "Parsing
queries" section in PostgreSQL
docs
sqlPlainToTSQuery :: String -> Field SqlTSQuery Source #
Call plainto_tsquery.
sqlToTSQuery :: String -> Field SqlTSQuery Source #
Call to_tsquery on the input string.
Internals (mostly)
to_pgTSQuery :: String -> Field SqlTSQuery Source #
Converts a String into a Postgres' tsQuery by calling to_tsquery on the input string.
plainto_pgTSQuery :: String -> Field SqlTSQuery Source #
Converts a String into a Postgres' tsQuery by calling plainto_tsquery on the input string.