Led & Sustained by

G2one Logo

Developed with

Intellij

Powered by

Spring

Searchable Plugin - FAQ

FAQ

Contribute!

This FAQ is a work in progress!

If you have a useful question and answer or have solved an issue that others may find helpful please add it.

Negative numbers are indexed as positive

This is probably because the number is being "tokenized" 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: "un_tokenized"

class Idea {
        static searchable = {
            votes index: 'un_tokenized'
        }
        int votes
        // ...
    }

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:

  • 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 call searchableService.indexAll() to perform a complete index at any time



    You can also perform a bulk-index in a separate thread easily like:



    Thread.start {
        println "forked bulk index thread"
        searchableService.indexAll()
        println "bulk index thread finished"
    }



    Which is a good thing since whilst performing a bulk-index Compass does not actually destroy the current index until the bulk-index is finished, so if you have a previous index you can do searches even while the index is being refreshed.



  • If mirroring is enabled (default is on) and you are creating domain classes in your BootStrap#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 = {
        }
    }
</