How to search result in Grails by the first match letters in word in Grails?
For example such query: findBy...("Moscow")
must be have output: "mosquite", "moschino", etc.
What you're looking to do here is easy if the scope is very narrow. If you only want to search the first N matching chars - you could use the findBy[domainClass]Like
. You can find the documentation here.
An example would be something like this:
def size = params.query.size();
def results = Thing.findByNameLike("${params.query[0..size]}%") // search by length of query
However, this is most likely way to narrow for what you're really looking to do. It may get you started but, if you want to get serious about search you need additional tools. Take a look at the Searchable plugin located here. It uses the Lucene engine which is an amazing tool and possibly the best way to do text based search in your domain.
Good luck!