Using augocomplete

Discussion in 'Programming' started by Triexa, Oct 30, 2007.

  1. #1
    I am working on implementing an autosuggest feature on a very large website. It will be used from a database of approximately 300,000 items. Clearly this would be a lot of queries and bog down the server with the searching and returning of results.

    Apart from "front-end" things like adding a delay before suggesting, suggesting only after X letters, etc. is there anything else I can do on the front end? More importantly, what about on the backend?

    The best solution I have thus far is to cache the results of a search term to a file and use those in the future. Of course, I would then end up with hundreds of thousands of files. Good solution?

    Any other ideas? Thanks!
     
    Triexa, Oct 30, 2007 IP
  2. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You have already picked up on the two obvious parts, only do the call back after 3 or more characters and cache the results - using .Net and MS SQL we wouldnt cache to a file but allow the environment to use the default caching with an onchange test
     
    AstarothSolutions, Oct 31, 2007 IP
  3. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I've never done this before but if I were to do it, I'd also be sure to:
    1) only return a maximum of maybe 15 or 20 results (or, alternatively, return NOTHING unless the full set of alternatives is in the range of maybe 50 or 60)
    2) when the user finally does the search, I'd increment a number in the database. That way, when looking for suggestions I can sort by the number of searches already on the phrases and return those phrases that have been searched on the most.
     
    TwistMyArm, Oct 31, 2007 IP
  4. schoash

    schoash Active Member

    Messages:
    291
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #4
    I would cache it with mysql not in files..
    And make a fulltext index on the table you use
     
    schoash, Oct 31, 2007 IP