You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
It isnt possible to do generic matching searches in firestore. You only get >=, =, <= stuff
Additional context
Most apps allow users to search app content. For example, you may want to search for posts containing a certain word or notes you've written about a specific topic.
Cloud Firestore doesn't support native indexing or search for text fields in documents. Additionally, downloading an entire collection to search for fields client-side isn't practical.
Solution: Algolia
To enable full text search of your Cloud Firestore data, use a third-party search service like Algolia. Consider a note-taking app where each note is a document:
// /notes/${ID}
{
owner: "{UID}", // Firebase Authentication's User ID of note owner
text: "This is my first note!"
}
// Initialize Algolia, requires installing Algolia dependencies:
// https://www.algolia.com/doc/api-client/javascript/getting-started/#install
//
// App ID and API Key are stored in functions config variables
const ALGOLIA_ID = functions.config().algolia.app_id;
const ALGOLIA_ADMIN_KEY = functions.config().algolia.api_key;
const ALGOLIA_SEARCH_KEY = functions.config().algolia.search_key;
const ALGOLIA_INDEX_NAME = 'notes';
const client = algoliasearch(ALGOLIA_ID, ALGOLIA_ADMIN_KEY);
------
// Update the search index every time a blog post is written.
exports.onNoteCreated = functions.firestore.document('notes/{noteId}').onCreate((snap, context) => {
// Get the note document
const note = snap.data();
// Add an 'objectID' field which Algolia requires
note.objectID = context.params.noteId;
// Write to the algolia index
const index = client.initIndex(ALGOLIA_INDEX_NAME);
return index.saveObject(note);
});
------
var client = algoliasearch(ALGOLIA_APP_ID, ALGOLIA_SEARCH_KEY);
var index = client.initIndex('notes');
// Perform an Algolia search:
// https://www.algolia.com/doc/api-reference/api-methods/search/
index
.search({
query
})
.then(function(responses) {
// Response from Algolia:
// https://www.algolia.com/doc/api-reference/api-methods/search/#response-format
console.log(responses.hits);
});
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
It isnt possible to do generic matching searches in firestore. You only get >=, =, <= stuff
You need to use third party API like ANGOLA. Se:
https://firebase.google.com/docs/firestore/solutions/search
Describe the solution you'd like
Describe alternatives you've considered
Additional context
Most apps allow users to search app content. For example, you may want to search for posts containing a certain word or notes you've written about a specific topic.
Cloud Firestore doesn't support native indexing or search for text fields in documents. Additionally, downloading an entire collection to search for fields client-side isn't practical.
Solution: Algolia
To enable full text search of your Cloud Firestore data, use a third-party search service like Algolia. Consider a note-taking app where each note is a document:
The text was updated successfully, but these errors were encountered: