Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6239495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:24:06+00:00 2026-05-24T11:24:06+00:00

I have a Ruby/Sinatra application deployed on Heroku and I am using the IndexTank

  • 0

I have a Ruby/Sinatra application deployed on Heroku and I am using the IndexTank plugin to provide Full Text Search capability.

I am currently using the out of the box autocomplete functionality as per the IndexTank Autocomplete Documentation

Currently I have indexed my documents such that the default :text field contains the city name and country name of a document. ie:

@index.document("1").add({:text => "London England"})

When I do a search in the default autocomplete field it does in fact work and return a result, however not what I would have expected, or liked.

When I type in ‘lon‘ into the field, it returns ‘london‘. This is indeed the correct document but I was hoping that it would actually return me ‘London England‘.

Does anybody know how I go about modifying the data that is rendered in the autocomplete field dropdown so that it displays ‘London England‘ when I search for ‘lon‘?


UPDATE

I have also tried the InstantLinks functionality as suggested in the comments but this also does not quite do what I need to do. It seems that both solutions do about 80% of what I need, but unfortunately I need something extra.

The two things about InstantLinks that don’t work as I need is:

  • While I can select which field from the index to display in the drop down (which is what I couldn’t do with the Autocomplete functionality), when I use the arrow keys to select the options in the drop down, the selected option does not display in the text field.

  • When I do select an entry from the drop down, I am taken to another page, the URL of which is supposed to have been pulled from the index. All I want to happen is the value of the entry selected to be populated into the original text field.

So, unfortunately I can’t see how InstantLinks is going to give me the functionality I am after either.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:24:07+00:00Added an answer on May 24, 2026 at 11:24 am

    Ok, so I finally worked out a way to solve my problem however, I was not able to use either the Autocomplete or InstantLinks functionality provided by IndexTank.

    In short what I did was use the out of the box jQuery autocomplete widget (which I know the IndexTank Autocomplete uses under the covers) to call a restful service I created which queries the IndexTank index.

    First I created the restful service in my Sinatra Application

    get '/index/' do
        term = params['term']
    
        #Query IndexTank index using the IndexTank::Client
    
        #Parse index search results and return an array of the suggestions as JSON
    end
    

    Next, I used the jQuery autocomplete widget to use my restful service as a remote source. First there is my HTML input:

    <form id="search_form" action="/" method="POST">
        <input id="search_field" name="search_field" type="text">
    </form>
    

    Then the javascript to bind the autocomplete widget to the input:

    $(document).ready(function(){
        $("#search_field").autocomplete({
          source: function(request, response) {
            $.ajax({
              url: "/index/",
              dataType: 'json',
              data: { term: request.term },
              success: function(data) {
                response($.map(data, function(item) {
                  return {label: __highlight(item, request.term),
                    value: item};
                }));
              }
            });
          },
          minLength: 2
        })
        .data( "autocomplete" )._renderItem = function( ul, item ) {
          // only change here was to replace .text() with .html()
          return $( "<li></li>" )
            .data( "item.autocomplete", item )
            .append( $( "<a></a>" ).html(item.label) )
            .appendTo( ul );
        };
      });
    
      function __highlight(s, t) {
        var matcher = new RegExp("("+$.ui.autocomplete.escapeRegex(t)+")", "ig" );
        return s.replace(matcher, "<strong>$1</strong>");
      }
    

    And there you have it, an autocomplete field that queries an IndexTank index and displays the desired index field in the suggestions drop down.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does Ruby have any tools along the lines of pylint for analyzing source code
I have a Ruby on Rails Website that makes HTTP calls to an external
I have some Ruby code which takes dates on the command line in the
I have a Ruby DateTime which gets filled from a form. Additionally I have
I have a Ruby script that generates a UTF8 CSV file remotely in a
I have a Ruby script in my Rails app that I use to load
I am running Ruby and MySQL on a Windows box. I have some Ruby
I've looked at this and it wasn't much help. I have a Ruby program
In Ruby I have often written a number of small classes, and had a
In Ruby we have the 'bang' method capitalize! which has the strange behavior of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.