Pregunta

I have Domain :

class Listing {
  String name
  Address address
  static searchable = {
    address component: true
    only: ['name']
  }
  static constraints = {
    address nullable: true
  }
}

I want to have in search index only object with address !=null. Is it achievable by configuration?

¿Fue útil?

Solución

Lucene doesn't work that way. You can only search by fields and values that exist, and you cannot directly check if the field is present, SQL's "is null" check cannot be done here. To implement what you need, you'll have to add something like boolean addressPresent, and set it to true if the address is filled up. Then in your query you have to add additional clause to check the addressPresent field

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top