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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:38:10+00:00 2026-06-04T03:38:10+00:00

I’m implementing an autocomplete that will allow a user to enter in partial text

  • 0

I’m implementing an autocomplete that will allow a user to enter in partial text that will then be matched against 4 different columns in a table. Here is a basic example:

+------------+-----------+--------+-----------------+
| first_name | last_name | login  | email           |
+------------+-----------+--------+-----------------+
| John       | Smith     | jsmith | jsmith@foo.bar  |
| Johnny     | Ringo     | ringo  | ringer@hmm.okay |
| Bob        | Jones     | bjones | j1234@xyz.abc   |
| Jane       | Doe       | doej   | doedoe@blah.umm |
+------------+-----------+--------+-----------------+

When the user enters “jo”, I want to match the records from this table where at least one of those four columns matches the pattern “jo%”. For this example, only the first two would match due to their first_name column values. If the search were “js”, then only the first record would match due to its login and email column values. And so on. I’d also like to return the results ordered by similarity, where the first result is the “closest match”, and so on down the results (standard autocomplete behavior).

I’ve currently been trying to solve this problem using UTL_MATCH, and code that produces the following query:

SELECT first_name,
  last_name,
  login,
  email,
      (  utl_match.jaro_winkler_similarity(first_name, 'js')
       + utl_match.jaro_winkler_similarity(last_name, 'js')
       + utl_match.jaro_winkler_similarity(login, 'js')
       + utl_match.jaro_winkler_similarity(email, 'js')) similarity
FROM users
WHERE LOWER(first_name) LIKE LOWER('js%')
OR LOWER(last_name) LIKE LOWER('js%')
OR LOWER(login) LIKE LOWER('js%')
OR LOWER(email) LIKE LOWER('js%')
ORDER BY similarity DESC

The results aren’t as accurate as I’d like them to be, and I’ve seen autocompletes in the wild that work the way I’d like mine to work, but have no idea how they’re implemented on the back-end.

Can anyone point me in the right direction?

  • 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-04T03:38:12+00:00Added an answer on June 4, 2026 at 3:38 am

    Searching is always fun. You’ve started a very good basic approach. What I usually do is create a secondary table loaded via trigger. The trigger load a primary key from your users table and the second column is the “search” column. In your example, every row would yield 4 rows. Make sure you store your results in upper case, so you can index the columns and Oracle will use the index since you are sticking with your like syntax. It requires an extra table, however the table can be maintained via triggers.

        create table searcher
        (
        user_id  number, --FK back to users
        search_column  varchar2(50) -- or whatever size column is appropriate
        );
    
        select u.first_name, u.last_name, u.login. u.email,
    utl_match.jaro_winkler_similarity(search_column, 'js')
        from users u
        join
        searcher s
        on (u.user_id = s.user_id)
        where s.search_column like upper('js%')
        order by 5;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a

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.