#106 new

Add autocompletion

Reported by haitham | March 30th, 2010 @ 11:52 AM | in 1.3

Add autocomplete/autosuggest functionality by merging changes from this forked branch:


Comments and changes to this ticket

  • mat

    mat March 30th, 2010 @ 11:54 AM

    • Tag changed from autocomplete to autocomplete, v1.2
  • mat

    mat March 30th, 2010 @ 11:58 AM

    • Milestone set to Feature Requests
  • mat

    mat March 30th, 2010 @ 12:00 PM

    Hey, this is a really nice-looking patch, but can you add some tests?

  • haitham
  • mat

    mat March 31st, 2010 @ 10:00 AM

    Thanks for adding those tests. This looks like a good starting point for autocomplete functionality but when that functionality goes into core Sunspot, I'd like for it to be fully supported in the Sunspot stack (both indexing and searching). The idea of doing the autocomplete searches from the client side is a nice one, but since it requires that Solr be world-accessible, I don't think it's realistic for most production setups.

    So, my suggestion would be to keep the client-side stuff as a plugin, and you, I, or someone else can use the indexer patches as a starting point for full round-trip autocomplete support in Sunspot.

  • greggersh

    greggersh October 26th, 2010 @ 11:49 AM

    • Milestone order changed from “0” to “0”

    I've forked haitham's original contribution and removed the client-side javascript stuff and have been working towards integrating this more directly into Sunspot. What I have so far is the ability to say (in a Rails model):

    searchable do
    autosuggest :field_name autocomplete :another_field_name, :using => :field_name end

    Which will index a field using haitham's autosuggest/autocomplete types to index the given fields.

    What I'd like to do is get some advice/feedback on how to integrate on the other side of things; what I'm doing now in the mean time is:

    Model.search do
    adjust_solr_params do |params|

    params[:q] = "field_name_as:#{query}"

    end paginate :page => 1, :per_page => num_results end

    which works, but is obviously not the best what to go about things. I'm wondering what you think would be the best way to do this, if it's something like:

    Model.autosuggest do
    autosuggest_query "what is" ... end

    or something like this:

    Model.search do
    autosuggest_query "what is" ... end

    I kind of feel like the latter is a better way to do it, but I'm not sure. Very open to suggestions.

    I'm working from here: http://github.com/greggersh/sunspot


  • mat

    mat December 27th, 2010 @ 02:22 PM

    • Milestone changed from Feature Requests to 1.3
    • Tag changed from autocomplete, v1.2 to feature patch
    • Milestone order changed from “79” to “0”
  • mat

    mat December 27th, 2010 @ 02:28 PM

    • Tag changed from feature patch to feature, patch
  • greggersh

    greggersh December 6th, 2011 @ 11:34 AM

    For various reasons, I deleted my fork with my autocomplete code. I still have it locally and am going to try to apply it to my current fork of sunspot. In the mean time, if anyone wants this code, please get in touch with me and I'll send a patch or something like that.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Awesome Solr interaction for Ruby

People watching this ticket