2

I am planning to develop a small search engine with auto complete feature based on the key entered contained in database (somewhat like google). Is there a recommend approach to performing the auto-completion. I'm doing it in java.

AlwaysALearner
  • 6,320
  • 15
  • 44
  • 59
  • I don't think it's a well-phrased question but I don't think it warrants closing – Brian Agnew Dec 14 '12 at 12:27
  • @BrianAgnew I voted to close because it's highly subjective. There is no right answer with this type of "How do I...?" question. Maybe a better fit for http://programmers.stackexchange.com/. – Duncan Jones Dec 14 '12 at 12:29
  • autocompletion based on what? basicly you should just have a class `Dictionary` with an `ArrayList` in it and do some algorythm on it – SomeJavaGuy Dec 14 '12 at 12:31
  • It's funny how there are already two answers when you haven't even told us the UI framework you want to use. Some frameworks already provide everything you need for auto-completion, for others you might have to do it yourself. – Cephalopod Dec 14 '12 at 12:34
  • @Arian i am open to suggestions regarding the UI framework. – AlwaysALearner Dec 14 '12 at 12:37
  • So your actual question is "Which UI framework should I use?". If your app will run in the browser, then jquery; if it's a desktop application, then javafx2 or swing; if it's an eclipse plug-in, jface. Just build your UI basics, and when that works, ask again about auto-completion. – Cephalopod Dec 14 '12 at 12:39

3 Answers3

2

It's not clear to me how this app is deployed etc., and I've read it (correctly or incorrectly) as a requirement for a bash-like autocomplete feature.

JLine is a command-line library for Java. It provides cursor-key navigation, history and completion. Unfortunately the doc isn't great, but start with the Completor interface.

If you're after a web interface, I would take a look at DWR (which exposes Java objects as Javascript objects) and implement auto-complete as per this post.

Community
  • 1
  • 1
Brian Agnew
  • 268,207
  • 37
  • 334
  • 440
1

You should subscribe to various events (as required) similar to TextChanged

See these questions:

Java equivalent to C# TextBox TextChanged event

Auto complete textbox in Java Swing

swing autocomplete text field / drop down

Community
  • 1
  • 1
Azodious
  • 13,752
  • 1
  • 36
  • 71
0

Its not that difficult. You can use java along with jquery auto complete plugin.

Here you just need to make a call like :

 $("#id").autocomplete("MyJSP.jsp");

So your background processing is done by your java and this loads the features with the auto complete plugin. Easy enough ! You can take a look at this link .

They have a nice Spring way of doing things too .

The Dark Knight
  • 5,455
  • 11
  • 54
  • 95