wiki icon indicating copy to clipboard operation
wiki copied to clipboard

feat: sqlite3 page content search module

Open dzruyk opened this issue 2 years ago • 4 comments

New search module for sqlite3. (using fts5). The module allows to search by page content like implemented in server/modules/search/postgres module.

The module allows you to use expressions for searching(similar to ts-query module). Supported types of expressions:

  • a b c d -- "a" AND "b" AND "c" AND "d"
  • a,b,(c d) -- "a" OR "b" OR ("c" AND "d")
  • head* -- all words with "head" preffix
  • a b (!c,!d) -- "a" "b" NOT ("c" AND "d")
  • "foo !bar !baz" -- "foo !bar !baz"

Since Sqlite does not support OR NOT (...) expressions search query may throw errors on some inputs (a b (c, !d) for example )

dzruyk avatar Jan 12 '23 21:01 dzruyk

Convert to draft, due to some knex troubles with index rebuild

Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a transacting(trx) call?

dzruyk avatar Jan 13 '23 09:01 dzruyk

The rebuild function has been rewritten.

It looks like knex only supports one sqlite database connection. I believe the error was caused by multiple knex function calls inside the pipeline.

await pipeline(
  WIKI.models.knex.column(...).select(),
  
  new stream.Transform({
    objectMode: true,
    transform: async (page, enc, cb) => {
      await WIKI.models.knex.raw(...).
      cb()
    }
  })
)

dzruyk avatar Jan 15 '23 23:01 dzruyk

I cleaned up the engine.js file, but the match-query.js needs some reformatting too, so that it conforms to StandardJS (e.g. always use braces for if statements, use const when variable is not reassigned afterwards, no dangling commas, etc.)

NGPixel avatar Jan 29 '23 23:01 NGPixel

Thx, I cleaned up the match-query.js.

Almost all warnings have been fixed.

There are still some warnings at the definition of this.knownLexemes. But I doubt whether it is worth rewriting it and how critical these warnings are.

  match-query.js:125:19: Object properties must go on a new line if they aren't all on the same line. (object-property-newline)
  match-query.js:125:31: Object properties must go on a new line if they aren't all on the same line. (object-property-newline)
  match-query.js:125:31: Unnecessarily quoted property 'not' found. (quote-props)
  match-query.js:126:19: Object properties must go on a new line if they aren't all on the same line. (object-property-newline)
  match-query.js:126:19: Unnecessarily quoted property 'and' found. (quote-props)
  match-query.js:127:18: Object properties must go on a new line if they aren't all on the same line. (object-property-newline)
  match-query.js:127:18: Unnecessarily quoted property 'or' found. (quote-props)
  match-query.js:127:30: Object properties must go on a new line if they aren't all on the same line. (object-property-newline)

dzruyk avatar Jan 30 '23 23:01 dzruyk