pass array to PgSearch.multisearch

475 Views Asked by At

I am going to try using using PgSearch.multisearch in my app.

Is there a way to pass an array to PgSearch.multisearch() method?

search = PgSearch.multisearch('test1')

returns a record

search = PgSearch.multisearch(['test1', 'test2'])

returns empty array

1

There are 1 best solutions below

0
On BEST ANSWER

Search terms are separated by a space. This will search for results that match test1 and test2:

search = PgSearch.multisearch(['test1', 'test2'].join(" "))

To use an OR condition, you can initialize the multisearch:

PgSearch.multisearch_options = { using: { tsearch: { any_word: true }}}
search = PgSearch.multisearch(['test1', 'test2'].join(" "))