• Post Reply Bookmark Topic Watch Topic
  • New Topic

search functionality  RSS feed

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
In my project , I am providing a search facility to user , when user enter any keyword & enter , it search that keyword into number of statements and if any statement has that keyword then display that statement .

I used StringTokenizer for this purpose , but the comment is , it is not efficient , so can any body tell me efficient way of doing this & provide me some details , I am using J2SE 1.3 .

Thanks a lot .
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bummer on the 1.3 ... in 1.4 you could use regular expressions. Are you tokenizing to separate words, so you won't get a false positive for "key" in "keystone"?

Some random ideas ...

statement.indexOf( word ) // tokenize only if keyword is present

statement.indexOf(" " + word + " ") // match space delimited word only

(" " + statement + " " ).indexOf( ... ) // fix to match first or last word

Or use Lucene I plugged Lucene into my Wiki with a very small adapter, could help with examples if you like.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!