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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:20:42+00:00 2026-05-11T12:20:42+00:00

Lets say I have a FirstName > MiddleName > LastName hierarchy (~10k rows, for

  • 0

Lets say I have a FirstName > MiddleName > LastName hierarchy (~10k rows, for sake of the question). This means you could have ‘John > Mary-Anne > Eddy’ or ‘Eddy > John > Jacob’ row. The point being that the hierarchy makes little sense and is very foreign to the user (unlike, say, a Country > State > City structure).

Because its so unstructured and confused, I want to provide the user with an auto complete input box. As they type, it should search for possible substring matches, and when they ‘root’ their search string at a level, it will then restrict the results to below that level.

Now, because there are lots of people named ‘John’, it makes little sense that if they type ‘John’ they only get back results like

  • John > Allen > Alexander
  • John > Allen > Burschawitz
  • John > Allen … repeat 100 times …

Because they’ll never see the unique row ‘Jason > John > Smith’.

Instead, they should get back something like (‘*’ is just an arbitrary indicator to the user of ‘hey, lots more rows below this exist’):

  • John > Allen > *
  • Jason > John > Smith
  • Mike > John > *
  • Mary > Elena > Johnason

If they type ‘John > Al’ then the results would be limited to anything under ‘John >’, but should be grouped similarly to above.

I hope the explanation is clear. The requirements are a bit loose. Just reasonable ones so that a person can search through the tree and find what they are after.

Right now, I have some interesting SQL that looks for the search term in the row, figures out its position, does some substring’ing, group bys, and order by’s to get the above results, but its not performing well enough.

I’m trying to solve this problem on a typical LAMP stack (except with Oracle). Its not shared hosting, so I do have full control over the server. The data changes small amounts every few weeks, and the search results can stay stale for a reasonable amount of time (e.g, a cron that updates the search index isn’t out of the question).

  • 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. 2026-05-11T12:20:42+00:00Added an answer on May 11, 2026 at 12:20 pm

    Argh. Sorry I wasn’t able to describe my problem. Anyways, here’s the solution I came up with.

    Basically, create a second table from the 3-column table that contains all the distinct values for each successive level of the hierarchy, as well as a column to indicate the depth of that row in the hierarchy.

    E.g. From mytable(A, B, C), create search_t(A, B, C, level)

    So, with ‘One > Two > Three’, you create 3 rows (A, B, C, level):

    • ‘One’, null, null, 1
    • ‘One’, ‘Two’, null, 2
    • ‘One’, ‘Two’, ‘Three’, 3

    When searching, you can constrain the level by picking a value for level and providing values for the upper-level columns:

    WHERE A='One' and level > 1 and (B like '%t%' or C like '%t')

    It can be a bit simplified and generic if you create a search_str column and perform the LIKE matching against that instead.

    WHERE A='One' and level > 1 and search_str like '%t%'

    In retrospect, this would probably have been more apparent if the data were already in an adjacency-list model.

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

Sidebar

Ask A Question

Stats

  • Questions 71k
  • Answers 71k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer To quote Wikipedia: In computer science, a programming language is… May 11, 2026 at 1:28 pm
  • added an answer Take a look at this ticket, your problem seems to… May 11, 2026 at 1:27 pm
  • added an answer You cannot forward declare enum values - and your workaround… May 11, 2026 at 1:27 pm

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.