LanceDB
Serverless Vector Database for AI らしい
ファイルシステムに書く
code:layout
/path/to/dataset:
data/*.lance -- Data directory
latest.manifest -- The manifest file for the latest version.
_versions/*.manifest -- Manifest file for each dataset version.
_indices/{UUID-*}/index.idx -- Secondary index, each index per directory.
_deletions/*.{arrow,bin} -- Deletion files, which contain ids of rows
that have been deleted.
Cloud Storage などにも書ける?
Cloud Run の FUSE からマウントしてできないかなあ
入力を Apache Arrow テーブルに変換して Lance Format で保存する
圧縮して削除済みの行を実際に消す、フラグメント数を100以下に抑える等
スキーマ定義
nullable=True にしても add する際に値には None 入ってないとだめ、省略したらエラーになる
クエリ
.where(... prefilter=True) ベクトル検索の前に絞り込む
table.search().where('id = 10').limit(1) ベクトル検索せずにフィルタ
値の取得
クエリ組み立ててほしい形式を呼ぶ
.to_list()
.to_pydantic(model) list of pydantic model が返る
.to_arrow()
.to_pandas() / .to_df()
table.count_rows()
全文検索
(そうじゃないベクトルの方は Approximate Nearest Neighbor = ANN)
table.create_fts_index("text") しておくと
table.search('文字列') を受け入れて全文検索する