Last updated by maurice
4 years ago
FAQ
This FAQ is a work in progress!Please add stuff that you think others may find helpful.
Negative numbers are indexed as positive
This is probably because the number is being "analyzed" during the index process.This process is usually applied to searchable text to normalize it and remove what are normally useless words and characters (punctuation for example).If you want to store the value of any searchable property exactly as it appears map that field with @index: "not_analyzed"@.class Idea {
static searchable = {
votes index: "not_analyzed"
}
int votes
// …
}Number Range searches don't return the expected results
Searching for objects with values for a numeric property in a certain range may return unexpected results.Say you have the following domain class:class Bug {
static searchable = {
votes index: "not_analyzed"
}
int votes = 0
// …
}def results = Bug.search("votes:[0 TO 20]")class Bug {
static searchable = {
votes index: "not_analyzed", format: "000000000"
}
int votes = 0
// …
}Startup is slow
The plugin performs a synchronous bulk-index of all the searchable domain class instances in your app by default.You have a few options:Bulk index at startup
You can change the default bulk-index-on-startup setting with configuration: you can disable it or fork a new thread.Even if you disable it, you can always callsearchableService.index() to perform a complete index at any timeYou can also perform a bulk-index in a separate thread easily like:Thread.start { println "forked bulk index thread" searchableService.index() println "bulk index thread finished" }
Disable mirroring during bootstrap
If mirroring is enabled (default is on) and you are creating domain classes in yourBootStrap#init you can temporarily disable mirroring while the bootstrap process runs then enable it and perform a complete index:class BootStrap {
def searchableService def init = { servletContext ->
searchableService.stopMirroring() for (i in 0..<10000) {
def thingie = new Thingie(description: "this right here is a thingie and it's number ${i}")
assert thingie.validate(), thingie.errors
thingie.save()
} searchableService.startMirroring()
searchableService.indexAll()
} def destroy = {
}
}