0

I have a database in Firestore like this "collection: posts->Document: PostId - >fields:(title, author, likes, content)" now I my website's search bar I want to search titles similar to those the user input, I want to show document if its time has any of the word given by the user

I tried this:

const sentence ="Looking For some posts";
const keywords = sentence.split(" ");

  const filteredKeywords = keywords.filter(
    (keyword) => !stopWords.includes(keyword)
  );
  console.log(filteredKeywords);
  const SearchIdeasRef = collection(db, "Ideas");
  const q = query(SearchIdeasRef, where("title", "in", filteredKeywords));
  const IdeaSnapshots = await getDocs(q);

But the problem is it checks the word like"posts" with the whole string of title

Raju
  • 9
  • 1
  • It sounds like you want the query to return documents where the `title` field contains the text that the user entered. Such text searches are not something Firestore supports though. See https://firebase.google.com/docs/firestore/solutions/search and the links I provided above. – Frank van Puffelen May 20 '23 at 14:03

0 Answers0