Indexing 'WHERE x LIKE %val%' type of query

Hi everyone,
I have a query of this kind:

SELECT cityname, countryname lat, lon
FROM bucket
WHERE cityname LIKE ‘%Madrid%’

I would like to know: what’s the best way to optimize it (through an INDEX)? Because I think that wildcard at the first position creates some trouble.
Thanks.

Check this

2 Likes

Thanks a lot, that’s exactly what I was looking for!