0

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

bonum_cete
  • 4,730
  • 6
  • 32
  • 56

1 Answers1

2

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(" "))
cschroed
  • 6,304
  • 6
  • 42
  • 56