How to get the relevance matching using java API?


I'm searching my data in the index, I want to get that most relevance
matched data from index.for example i'm searching data "abcd" and my
inex contain "a","ab", "abc" ,then most relevence matching is "abc"
for search data. My requirement is that if more than one hit is found
then i have to select the most relevance data.
please tell me which java API and it's method will help me to get this
type of searching.