Data search

-1

I'm not sure what to do, but I'd like to do this in jsp. I want the client to type the word to search mysql database. Example leonardo dai I'll have multiple database names, only the client that will search the data base he typed wrong leotard and did not return anything because there is no such name but want to do something he breaks all the characters and do search in the bank with all similar letters of an arraylist example words he typed that has more 5 equal words nume array list.

String reqDescricao = 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);

To do this in java and jsp.

I've done it so I want to change it, I want to break the word in letters and I want to bring all the words that have an example up to 5 letters in the same bank.

    
asked by anonymous 28.07.2017 / 01:38

1 answer

0

The feature you described, break down into letters and consider up to a valid amount, is the perfect description of Levenshtein's algorithm implementation.

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

In this Stack Overflow link you will find the MySQL Stored Procedure implementation of this function, which you will use during the search, within the WHERE of query class.

link

    
28.07.2017 / 03:05