@codelic/searchforfirestorebyngram
TypeScript icon, indicating that this package has built-in type declarations

1.0.25 • Public • Published

searchForFirestoreByNGram

firestore内で全文検索を実装するためのモジュール 

使用時の注意

  • ネストしているフィールドのテキストを検索対象としては取ってこれない
  • 現時点のバージョンではOR検索ができない
  • スペースを挟んだキーワードを検索する場合はAND検索となる

使用方法

cloud functionsの追加設定

const firestore = getFirestore(app);

import {
  functionFactoryForWriteHook,
  functionFactoryForSearchRequest,
} from "@codelic/searchforfirestorebyngram";
// onWriteでデータの追加されたタイミングで検索用のDBへ検索用のドキュメントを追加
export const createBinaryGrumDoc = functionFactoryForWriteHook(
  firestore,
  "users"
);
// 検索リクエストを投げる先のAPI
export const getSearchRequest = functionFactoryForSearchRequest(firestore);

検索をかけたい場合のリクエストの中身のタイプ情報

type query ={
    collectionName: string; // 対象のコレクション名 例)User
    targetFieldName: string; // 検索をかけたいフィールド名 例)name
    searchWord: string; // 検索キーワード 例)山田
}

制限に関して

  • firestoreドキュメントの最大情報量が1MBなので検索用のドキュメントが1MB超えるようであれば検索自体難しい

Readme

Keywords

none

Package Sidebar

Install

npm i @codelic/searchforfirestorebyngram

Weekly Downloads

392

Version

1.0.25

License

ISC

Unpacked Size

39.1 kB

Total Files

50

Last publish

Collaborators

  • furukawa_code
  • code-daiki2170
  • j-hiwatashi
  • takamitsuogawa
  • kazumaparrot
  • whitecrow
  • mesqueeb
  • keijunakashima
  • adachi-codelic
  • tdk0718