Lucene - Search Filter

Asked

Viewed 13 times

0

I am trying to implement search filters, passing words or phrase. I implemented 4 filters: Aproximação, Deve conter a frase, Deve conter alguns dos termos and DEVE CONTER TODOS OS TERMOS.

The question is in this last filter, it means that if I don’t know someone’s last name, but I know that his name is "Bruno" and that he stole a bike, if I type "BRUNO BICICLETA" the system returns me every record that these two words are, regardless of the order they were typed in. For example, in the filter Deve conter a frase the system returns exactly the same sentence order. In the filter deve conter todos os termos I need you to return to me all the terms I researched in order or out of order. Could someone help me?

QUERY CLASS

public Query phrase(String sentence, String field) {
return phrase(sentence, field, 0);
}

public Query phrase(String sentence, String field, int slop) {
if (isEmpty(sentence)) {
return null;
}
return queryBuilder.phrase()
.withSlop(slop)
.onField(field)
.sentence(sentence)
.createQuery();
}

CASE PASSING THE PHRASE

case PHRASE:{
        return b.should(
          b.phrase(value,CONTENT)
        );
}
No answers

Browser other questions tagged

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