1

Scenario

Given I am a tutor

When I type comma separated list of search terms

e.g math,accounting

Then Expected

I should be able to see different documents having map field key term set to true

Then Actual

I get empty result

When I type comma separate terms that relates to the same document

I get the actual result

Question

Is there or Operation for cloud firestore.

Kindly find below code snippet and screenshots:

Future<void> search(List<String> keywords) async {
    var docs = coursesRef.where('isDraft', isEqualTo: false);

    keywords.forEach((word) {
      String term = word.trim().toLowerCase();
      print("$term\n");
      docs = docs.where('searchTerms.$term', isEqualTo: true);
    });

    QuerySnapshot query = await docs.getDocuments();

    courses = [];
    query.documents.forEach((doc) {
      Course course = Course.fromDoc(doc);
      courses.add(course);
    });

    notifyListeners();
  }

Below screen shot for sample Map<String, bool>

enter image description here

xiarnousx
  • 575
  • 6
  • 18

0 Answers0