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 9041357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:13:19+00:00 2026-06-16T10:13:19+00:00

There is this jquery-autocomplete plugin which allows you to search for the exact string

  • 0

There is this jquery-autocomplete plugin
which allows you to search for the exact string only..

So lets say this is the data..

   [
        ['apple is good'],
        ['apple grows on tree'],
        ['the tree and the apple'],
        ['red apple'],
        ['apple tree']
    ]

Now searching for “apple” should show all.

But when typing “apple tree” it only returns back “apple tree”.
I want it to return the smart results (2,3 and 5).

  • “apple grows on tree”
  • “the tree and the apple”
  • “apple tree”

This means: it should re-evaluate the search again for each word (but filter it from the already filtered results)

This plugin allows you to provide your own search..

what can the refined search which will enable us to smartly search look like?

It needs to ignore whitespace and split the search query in to words to evaluate each word one after the other…

$("#textInputEle").autocomplete({
    url:"path/to/data.json",
    filter: function(result, filter) {
     //whats should this function be?
    }
});
  • 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-06-16T10:13:20+00:00Added an answer on June 16, 2026 at 10:13 am

    You use the filter option to supply your own filtering logic.

    The function you supply takes result and filter parameters. The filter parameter is what the user has searched for. The result parameter is an item in the list of suggestions. Your function must return true (if the suggestion is a match), or false (if the suggestion is not a match).

    The logic to do what you’re trying to accomplish could look something like this:

    1. Split the result you’re passed by space (" ") into an array of terms.
    2. Create a regular expression out of each string in the array of terms
    3. Ensure what the user typed matches each regular expression

    That would look something like this:

    $("#auto").autocomplete({
        data: [
            ['apple is good'],
            ['apple grows on tree'],
            ['the tree and the apple'],
            ['red apple'],
            ['apple tree']
            ],
        filter: function(result, filter) {
            var terms = filter.split(" "),
                match = true,
                i = 0,
                regex;
    
            for (; match && i < terms.length; i++) {
                regex = new RegExp(terms[i]);
                match = match && regex.test(result.value);
            }
    
            return match;
        }
    });
    

    Example: http://jsfiddle.net/ztkX2/1/

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

Sidebar

Related Questions

jQuery autocomplete plugin sent request like this mysite.com/suggestion?term=Sadegh is there any way to change
Although there are a lot of jquery autocomplete code in this forum. However I
Is there any jQuery plugin for progressive light glow effect like this ?
I'm using the JQuery Autocomplete plugin, with l ocal data stored in a array
I am using this JQuery autocomplete plugin . It works, and it's simple. But
im working on this jquery data entry form in which i need a specific
I have a form field which uses Jorn Zaefferer's autocomplete jQuery plugin. If i
On the ( now old ) jQuery autocomplete plugin there was the functionality that
I have a jquery autocomplete textbox. http://docs.jquery.com/UI/Autocomplete#events The spec there shows this: Triggered when
I've got a form that uses the jquery autocomplete UI plugin, http://jqueryui.com/demos/autocomplete/ , which

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.