Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fulltext search for stop id #24

Open
romanofski opened this issue Feb 8, 2017 · 0 comments
Open

Fulltext search for stop id #24

romanofski opened this issue Feb 8, 2017 · 0 comments

Comments

@romanofski
Copy link
Owner

The implementation with #23 only uses like SQL instead of a fulltext search. SQLite3 actually provides full text search. A quick attempt failed however, just adding additional instructions:

addDatabaseIndices ::
  (MonadIO m, MonadResource m)
  => ReaderT Sqlite.SqlBackend m ()
addDatabaseIndices = do
  mapM_ (\x -> withStmt (T.pack x) []) indices
  return ()
    where indices = [ "create index stop_time_index ON stop_time (stop_id);"
                    , "create index trip_index on trip (trip_id, route_id, service_id);"
                    , "create index route_index on route (route_id);"
                    , "create index calendar_index on calendar (service_id);"
                    , "create index stop_index on stop (stop_id, code);"
                    , "CREATE VIRTUAL TABLE stopsearch USING fts3(stop_id, code, name)"
                    , "insert into stopsearch(stop_id, code, name) select stop.stop_id, stop.code, stop.name from stop"
                    ]

When creating the database it failed with:

[Debug#SQL] INSERT INTO "update_process"("when","status") VALUES(?,?); [PersistDay 2017-02-07,PersistBool True]
[Debug#SQL] SELECT "id" FROM "update_process" WHERE _ROWID_=last_insert_rowid(); []
[Debug#SQL] INSERT INTO "import_started"("upid") VALUES(?); [PersistInt64 1]
[Debug#SQL] SELECT "id" FROM "import_started" WHERE _ROWID_=last_insert_rowid(); []
[Debug#SQL] create index stop_time_index ON stop_time (stop_id);; []
[Debug#SQL] create index trip_index on trip (trip_id, route_id, service_id);; []
[Debug#SQL] create index route_index on route (route_id);; []
[Debug#SQL] create index calendar_index on calendar (service_id);; []
[Debug#SQL] create index stop_index on stop (stop_id, code);; []
[Debug#SQL] CREATE VIRTUAL TABLE stopsearch USING fts3(stop_id, code, name); []
FAIL
        Exception: SQLite3 returned ErrorError while attempting to perform step.

If the need arises, perhaps use fts3 to support fulltext search.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant