searchable icon indicating copy to clipboard operation
searchable copied to clipboard

Doesn't consider the whole text

Open saurabh-pathak94 opened this issue 9 years ago • 3 comments

Hey! Suppose, there is a record - "The White Wizard", and I search for "White" or "wizard" it gives back null result. However, it works if I search "the", "The White", "White wizard". Thank for your help! @nicolaslopezj I've noticed that searching any word alone (in a record) except the first, gives null result.

saurabh-pathak94 avatar Jul 06 '15 06:07 saurabh-pathak94

I'll second that, I'm trying to search a description text field, and can only get matches from the first word as described above. It's really easy to implement this search, but @nicolaslopezj what can we do to make any part of the text searchable?

Thanks.

dfc1883 avatar Jul 08 '15 09:07 dfc1883

Use this https://github.com/jarektkaczyk/eloquence/wiki/Builder-searchable-and-more and you can make it work flawlessly in your case. Any of these will get you your The White Wizard row:

The
White
Wizard
The White
White Wizard
// or whole phrase only
"White Wizard"
"The White"

// also with wildcards
Wiza?d
* Wizard

and so on.

jarektkaczyk avatar Jul 08 '15 11:07 jarektkaczyk

Same issue met as @saurabh-pathak94 stated, but after I reduced the number of fields on $searchable->columns, the issue is gone. Anyone knows why?

UPDATE: it seems the problem can be fixed by changing ->search($query, null, true) to ->search($query, 1, true)

chiu0602 avatar Jan 04 '18 07:01 chiu0602