Well I found a way to "fix the issue" but i dont like it(because its a reindexAll()
). After I add the tag if I call:
searchableService.reindexAll()
It will work. I dont understand why the following wouldn't work:
static PersonTag addTag(String name, Person person){
if(person && person.id){
def tag = Tag.findOrCreate(name)
def t = new PersonTag(tag:tag, person:person)
t.save(flush:true)
t.index()
tag.reindex()
person.reindex()
return t
}
}