firestore full text search
v0.6.1
Firestore Full-Text Search는 Firestore 별 전체 텍스트 검색 기능을 제공합니다.
클라우드 기능에서 실행되며 성능이 뛰어납니다.
간단한 거꾸로 된 인덱스 유형 검색을 지원합니다.
npm install --save firestore-full-text-search import admin from 'firebase-admin' ;
import FirestoreFullTextSearch from 'firestore-full-text-search' ;
admin . initializeApp ( { ... } ) ;
const db = admin . firestore ( ) ;
// Specifies the collection in which to store the inverted index.
const fullTextSearch = new FirestoreFullTextSearch ( db . collection ( 'index' ) ) ;
// Set documents
const postData : Post = {
title : "What's Firestore Full-Text Search?" ,
content :
'Firestore Full-Text Search provides a Firestore-specific full-text search function. It runs on Cloud Functions and has excellent performance.' ,
created : admin . firestore . FieldValue . serverTimestamp ( ) ,
} ;
const docRef = postsRef . collection ( 'posts' ) . doc ( '1' ) ;
// WriteBatch is supported so that documents and search indexes can be stored atomically.
const batch = db . batch ( ) ;
batch . set ( docRef , postData ) ;
await fullTextSearch . set ( 'en' , docRef , { batch , data : postData } ) ;
await batch . commit ( ) ; // Search documents
const results = await fullTextSearch . search ( 'en' , 'firestore' ) ;