Multiple Fields Names in Full Text Search
How can I add more fields to search index query both in schema creation and during the search.
For example,
.searchIndex("search_name", {
searchField: "firstName",
}).
I would want to add the lastName as a search field too.
Can I make it look like this
.searchIndex("search_name", {
searchField: ["firstName", "lastName],
})
Or I would have to create another search index like this
.searchIndex("search_name", {
searchField: "firstName",
}).searchIndex("search_name", {
searchField: "firstName",
})
And If I do this, How do I make the query in my convex backend?
This is for single fields.
.withSearchIndex("search_name", q =>
q.search("firstName", queryText)
)
What would it look like for multiple fields?4 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
I think you can't rn, you need to create a new field and concat the two fields into a single field and seach that instead.
Thank you for your response.
Please can you give me a simple example to guide me better?
eg. if this is ur document in the DB
you would change the schema to become
and search the searchIndex instead of the firstName and lastName fields