Git Product home page Git Product logo

Comments (9)

mrkamel avatar mrkamel commented on May 26, 2024

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
Benjamin

from search_cop.

ghazel avatar ghazel commented on May 26, 2024

In your test case you've explicitly passed * to the search function. If the search cop model used LIKE instead, you wouldn't need to add the *, it would automatically append a %.

from search_cop.

mrkamel avatar mrkamel commented on May 26, 2024

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.

from search_cop.

ghazel avatar ghazel commented on May 26, 2024

fulltext has the benefit of finding any word with that prefix though, right? LIKE '%foo' only works on the first word.

from search_cop.

mrkamel avatar mrkamel commented on May 26, 2024

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 option :title, :fulltext => true, :fulltext_wildcard => true or similar to opt this feature in.

from search_cop.

ghazel avatar ghazel commented on May 26, 2024

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 LIKE word work but do a full table scan.

from search_cop.

mrkamel avatar mrkamel commented on May 26, 2024

Do you feel like creating a PR?

from search_cop.

aaronchi avatar aaronchi commented on May 26, 2024

This would be nice to have. It's available in pg_search

from search_cop.

mrkamel avatar mrkamel commented on May 26, 2024

I've added this feature in branch 23_fulltext_right_wildcard.
You're very welcome to try it out already.

from search_cop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.