Data search

Asked

Viewed 49 times

-1

good guys to with doubt here and I want to do the following in jsp I want the client to type One word to search mysql database example Eonardo then I will have several registered names of the database, only that the customer who will search in the data library he typed wrong Leotardo and did not return anything because there is no such name anymore want to do something that he breaks all characters and do search in the database with all letters similar to an arraylist example words that he typed that has more than 5 words equal in an array list.

String reqDescription = request.getParameter("searchName");

    String descricao = "%" + reqDescricao + "%";
    EntityManagerFactory factory;
    factory = Persistence.createEntityManagerFactory(AbstractWebCmd.PERSITENCE_UNIT);
    AlunoDAO dao = new AlunoDAO(factory);
    List<Aluno> alunos = dao.findByDescricao(descricao);

I’m doing in java and jsp.

i did so more I want to change I want to break word in letters and I want to bring all words that have example up to 5 equal letters in the bank I wait for help.

1 answer

0

The functionality you described, from breaking in letters and considering up to a valid amount, is the perfect description of the implementation of the Levenshtein algorithm.

For example, levenshtein('Leonardo', 'Leonarto') results in 1, that is, the distance between Leonardo and Leonarto is a difference, and if you accept up to, say, 5 differences away, then Leonardo would be a valid return to the search Leonarto.

In this Stack Overflow link you will find the Stored Procedure for Mysql implementation of this function, which you will use during the search, inside the key WHERE of query.

https://stackoverflow.com/questions/13909885/how-to-add-levenshtein-function-in-mysql

Browser other questions tagged

You are not signed in. Login or sign up in order to post.