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

  • SEARCH
  • Home
  • 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

I have a ruby application that executes ant as a subprocess using backtick. This
I'm building an application in ruby using the sinatra framework and am having trouble
I'm working on a ruby project using Sinatra as a framework and have a
I have a plain ruby application (it's not a Web app, so not using
I am building an Ruby application using Sinatra (over Rack/Thin) and I want to
I'm building a small Ruby application using DataMapper and Sinatra, and I'm trying to
I have my beginner Ruby application working perfectly on my local server using Rack
I'm looking for a lightweight Ruby web framework and have come across Sinatra and
I run a sinatra application with mongomapper. I have models called Movie(Document) and Cover(EmbeddedDocument).
I'm very new to ruby & Sinatra and I have a basic question: The

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.