I'm working on an app, which allows users to specify their skills and interests, and then get suggested jobs, based on their skills and interests.
Both are stored in a user document as an array:
skills: ['computers', 'blah-blah']
interests: ['whatever']
Each job is also stored in Firestore with a skills and an interests array (specified by the creator).
My question is, what would be the best way to find a job document which matches as many skills and interests as possible, based on the user making the request?
Just like what Frank and Dharmaraj already stated in the comments, I suggest that you further check the array-contains-any, for example:
import { query, where } from "firebase/firestore";
const skillsQuery = query(skillsRef,
where('skills', 'array-contains-any', ['computers', 'blah-blah']));
const interestsQuery = query(interestsRef,
where('interests', 'array-contains-any', ['whatever', 'etc']));
Just note the following limitations of array-contains-any:
array-contains-any support up to 10 comparison values.