javer / JaverSphinxBundle

Symfony bundle which provides integration of Sphinx search engine with Symfony using SphinxQL
MIT License
24 stars 19 forks source link

OR condition #4

Closed indapublic closed 4 years ago

indapublic commented 4 years ago

Hey! Thanks for your awesome library. Have a question. Is it possible to do OR condition? I want to find all occurrences with "foo" and "bar" for example

->match(["title", "content", "tag"], "foo")
->match(["title", "content", "tag"], "bar")

Something like that, but it works like AND condition.

indapublic commented 4 years ago

Tried with ->match(["title", "content", "tag"], "foo | bar") but not worked

javer commented 4 years ago

@indapublic If you want to use Extended query syntax as the value for match, you should specify true as the third argument:

->match(['title', 'content', 'tag'], 'foo | bar', true)

will be compiled to:

MATCH("@(title,content,tag) foo | bar")

Please note that you should sanitize user input to avoid injection, you can see in method Query::quoteMatch() all symbols which should be escaped. Passing true to the third argument of Query::match() disables automatic escaping.

indapublic commented 4 years ago

Oh, stupid me. Sorry. Found 'setQuery' but not third argument for 'match'. Thank you!