-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wildcard in fulltext mode #23
Comments
Hi, thanks for reporting. Just trying to reproduce, but my test case is running fine: def test_wildcard
expected = create(:product, :title => "Expected")
rejected = create(:product, :title => "Rejected")
results = Product.search("title:Expec*")
assert_includes results, expected
refute_includes results, rejected
end and generates ... WHERE (MATCH(`products`.`title`) AGAINST('Expec*' IN BOOLEAN MODE)) Could you please provide the full search cop model layout, search cop query and sql query generated? Thanks in advance |
In your test case you've explicitly passed |
Ah, ok. However, this behaviour is desired. Fulltext search usually works this way and if you don't want it, simply do not use the fulltext feature. |
fulltext has the benefit of finding any word with that prefix though, right? |
That's true. However, the use cases seem to be limited to me. Maybe you can give examples. I'd be ok, though, with an option |
That feature would work great for me. I'm a little skeptical about splitting on spaces and adding asterisks -- probably there should be escaping or something. My use case is simple keyword (prefix) search, where |
Do you feel like creating a PR? |
This would be nice to have. It's available in pg_search |
I've added this feature in branch 23_fulltext_right_wildcard. |
When searching without fulltext (and
:left_wildcard => false
) the query is constructed asfield LIKE 'foo%'
. However in fulltext mode, the query isMATCH(
table.
field) AGAINST('+foo' IN BOOLEAN MODE)
, which looks for exact matches instead of a wildcard type search, which would be+foo*
.So, it seems like fulltext query elements should have
*
appended automatically.The text was updated successfully, but these errors were encountered: