开发者

Grails searchable plugin: limitless results

The searchable plugin seems to default开发者_开发知识库 to only 10 results. How do I change this to return all results?

@ Bill I'm looking for something like this:

DomainClass.search("This is the query", [max:every_last_one_of_em])

I could put a limit of like 40 and probably be fine, but the purpose of this search is to give a human a list of similar things to disambiguate, so if some of the things are missing the stupid humans will likely use "assumption" to get the wrong answers.


From the documentation at: http://grails.org/Searchable+Plugin+-+Methods+-+search

Options affecting the return value
    max - The maximum number of results to return (default 10). Only used with result: "searchResult"

So it seems you'll need to pass in a Map of options to your search call, like:

DomainClass.search( "This is the query", [max:1000] )

Note, having an "unlimited" search result is a Bad Idea(TM). Figure out the max you want to handle and use that as your limit.

I would suggest having a "large" limit, if you must. If you get back that many, then do a further query to find out how many there are (there is an option for that too), and display a message to the user that "This is an incomplete set, please further restrict your view" or some such.

If you absolutely MUST show them all. Then use that count query (it's an option in the page I listed above), then resend the search using that count as the max.


Mikey to make the search return all results just remove the max field from the defaultMethodOptions.

You can find this declaration in Configuration -> Searchable.groovy

defaultMethodOptions = [
    search: [reload: false, escape: true, offset: 0, max: 10, defaultOperator: "and"],
    suggestQuery: [userFriendly: true]
]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜