rootlexR
Convex Community15mo ago
4 replies
rootlex

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?
Was this page helpful?