0

How can I perform a Firestore query that searches for documents with partial matches or multiple fields, instead of exact matches?

I'm using Vue2, this is my current syntax:

query = query.where("objectID", "==", this.state.docs.keyword)

I'm trying to query the result with keyword: "TX-200_FA" by fields ObjectID, CustomerName and SellerName.

The output I received only contains exact matches for the field ObjectID, which was not my intention. If I enter the keywords "200" or "TX", I want the results to be displayed as well.

Jinji
  • 1
  • 2
  • There is so many way to do that, Can you explain what is your intention? – flutroid Aug 17 '23 at 01:22
  • What do you mean by "partial match"? Please edit the question to give an example of what you are trying to do so we can be clear about a solution. – Doug Stevenson Aug 17 '23 at 01:29
  • Only prefix matches are possible natively. Although you can build some other types based on that, the best option if you want reasonable full text search is to use one of the full text search solutions documented here: https://firebase.google.com/docs/firestore/solutions/search. – Frank van Puffelen Aug 17 '23 at 02:24
  • Perhaps this [resource](https://medium.com/firebase-tips-tricks/how-to-filter-firestore-data-cheaper-705f5efec444) will help. – Alex Mamo Aug 17 '23 at 07:24

0 Answers0