質問

I'm using the searchable plug-in in my grails project,

I have a domain class like this:

class Item {
...
String dominantColor
String palette
...

static searchable = {
     ....
    only: ['title', 'description' ,'palette' , 'dominantColor']
}

dominantColor is a String containing a color name like :

Green

palette is a String containing a list of colors name like this :

["Desert sand","Dark jungle green","Outer Space","Dim gray","Slate gray","Army green","Dark electric blue","Cadet grey","Dark chestnut"]

and I'm trying to search only items with selected color, I tried like this:

def searchResult = Item.search({
    must(term("Item.publication", true))
    must(term("Item.Itemlist.isPublished", true))
    must{queryString(query)}
    if(params.color){
        String selectedColor = params.selectedColorName
        must{
            term('Item.dominantColor', selectedColor)
            term('Item.palette', selectedColor)
            }
        }
}).results

But doesn't work, can anyone help me figuring out what is wrong with my query?

Edit I noticed that

 must{term('proprityName ', value)

doesn't work with String value,

when i tried with only this , it work

  must(term("Item.publication", true))

but with this it didn't

  term('Item.dominantColor', "Green")
役に立ちましたか?

解決

My best guess is that your values input into the index are being analyzed, and are all lowercased.

When you construct your queries though, there is no analysis happening, so they won't be automatically lowercased. Try:

term('Item.dominantColor', "green")
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top