Coder Social home page Coder Social logo

noamt / elasticsearch-grails-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mstein/elasticsearch-grails-plugin

63.0 14.0 83.0 33.5 MB

The revived ElasticSearch grails plugin

Home Page: Based on Graeme Rocher initial stub. Note that it is still in early stage.

License: Other

Groovy 99.42% Shell 0.58%

elasticsearch-grails-plugin's People

Contributors

burtbeckwith avatar domix avatar donbeave avatar jameskleeh avatar kaerfredoc avatar lucaslward avatar m-r-c avatar magno32 avatar marcoscarceles avatar melix avatar mkuchin avatar mstein avatar nmfisher avatar noamt avatar peh avatar puneetbehl avatar rcracel avatar rpokorny avatar ruslan-atr avatar ruslan-khalitov avatar sgates avatar smaldini avatar spither avatar tcrossland avatar tuler avatar verglor avatar vincentjames501 avatar vsaar avatar yinonavraham avatar zhuravskiy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elasticsearch-grails-plugin's Issues

elasticSearchService.index() not working for manually deleted items

If an item is deleted manually from the database, the item continues to remain in the search index, so, e.g., if the item is a phoneNumber, and we search for the particular phoneNumber the search method continues to return the item even though it no longer exists in the DB.

If we call elasticSearchService.index(), the phoneNumber also continues to be returned from the search method. My guess is that the index() method will add items into the index, but I don't think it removes items that are no longer in the DB.

Incompatible with Elasticsearch-1.0.0

Hi,

I was unable to connect to the elastic search node in either node or transport mode. After trying to fix connectivity issues that were not there for a good long time, I saw that the current plugin uses an outdated version of the ES libraries. I went ahead and modified dependencies.groovy, and was then able to connect to the node.

    runtime 'org.elasticsearch:elasticsearch:1.0.0'
    runtime('org.elasticsearch:elasticsearch-lang-groovy:2.0.0.RC1') 

It seems to work until now (i am still evaluating the plugin). Is there a reason why this has not been comitted yet to the repository? Are there known issues? I couldn't find any here in the issue tracker.

GeoPoint field in component object not sent to ElasticSearch as required

We are facing a problem when the Domain instance is unmarshalled and JSON object is sent to ElasticSearch for a PUT request.

Environment :- Grails 2.2.4 , ElasticSearch 1.2.4 , ElasticSearch Grails Plugin 0.0.3.3
Example structure:-
Domain A{
..
GeoPoint location // Geopoint field location for Domain A
DomainB domainB

static embedded = ['location']
static searchable = {
domainB component: 'inner'
location geoPoint: true , component: 'inner'
}
}

Domain B{
...
GeoPoint geoPoint // GeoPoint field for Domain B
static embedded = ['geoPoint']
static searchable ={
geoPoint geoPoint: true
}
}

class GeoPoint {
Double lat
Double lon
static searchable = {
except = ['class', 'id']
root false
}
}

When instance of DomainB is sent to ElasticSearch, geoPoint field is translated as {lat: 36.5, lon: 77.5} whereas if an Instance of DomainA is sent, geoPoint field of DomainB is translated as {id: null, class: package.GeoPoint, lat: 36.5, lon: 77.5} which is causing the following error:-
Caused by: org.elasticsearch.ElasticsearchParseException: field must be either 'lat', 'lon' or 'geohash'

Investigating into the source code of the plugin, issue seems to be with the DeepDomainClassMarshaller.

if (DomainClassArtefactHandler.isDomainClass(propertyClass)) {
String searchablePropertyName = getSearchablePropertyName()
if (propertyValue.class."$searchablePropertyName") {
// todo fixme - will throw exception when no searchable field.
marshallingContext.lastParentPropertyName = prop.name
if(propertyMapping?.isGeoPoint())// geopoint check added
marshallResult += [(prop.name): (marshallingContext.delegateMarshalling(propertyValue, propertyMapping.maxDepth))]
else
marshallResult += [(prop.name): ([id: propertyValue.ident(), 'class': propertyClassName] + marshallingContext.delegateMarshalling(propertyValue, propertyMapping.maxDepth))]
} else {
marshallResult += [(prop.name): [id: propertyValue.ident(), 'class': propertyClassName]]
}
}

Let me know in case further details are required. Also, suggest if there are any workarounds for this with 0.0.3.3.

Thanks in Advance.

better search documentation

the documentation for groovy dsl in elastic search is very brief. it would be nice if the plugin documentation would go further than just showing bool { must { query_string }}

Support for nested types

First of all, thanks for an amazing plugin!

I'm running into some trouble doing a search on a one to many list of associated domain objects. Let's say I have a "Person" domain object with a List of "Qualifications". Each qualification has a type and a rating. The trouble is if I want to search for a person with a certain qualification type with a specified rating: elastic search will return all people with that qualification type if they have any qualification above that rating.

I'm wondering whether there's an easy way to specify a mapping as a nested type with this plugin. Based on what I read here: http://www.elasticsearch.org/blog/managing-relations-inside-elasticsearch/ it seems like what I should be doing.

Thanks again for your help.

BeanCreationException: Error creating bean with name 'indexRequestQueue'

Grails 2.2.4, JDK 1.7.0_45-b18, OSX 10.8.5
plugin version 0.0.2

When trying to start the application:

ERROR context.GrailsContextLoader - Error initializing the application: Error creating bean with name 'auditListener': Cannot resolve reference to bean 'indexRequestQueue' while setting bean property 'indexRequestQueue'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'indexRequestQueue': Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.codehaus.groovy.grails.orm.hibernate.support.AggregatePersistenceContextInterceptor' to required type 'org.grails.datastore.gorm.support.DatastorePersistenceContextInterceptor' for property 'persistenceInterceptor'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.codehaus.groovy.grails.orm.hibernate.support.AggregatePersistenceContextInterceptor] to required type [org.grails.datastore.gorm.support.DatastorePersistenceContextInterceptor] for property 'persistenceInterceptor': no matching editors or conversion strategy found

Config.groovy:

elasticSearch {
client.mode = 'local'
index.store.type = 'memory'
date.formats = ["yyyy-MM-dd'T'HH:mm:ss'Z'"]
client.hosts = [
[host:'localhost', port:9300]
]
defaultExcludedProperties = ["password"]
disableAutoIndex = false
bulkIndexOnStartup = true
maxBulkRequest = 500
datastoreImpl = 'hibernateDatastore'
}

DataSource.groovy:

dataSource {
driverClassName = "org.postgresql.Driver"
url = "jdbc:postgresql:xyz"
username = "postgres"
password = ""
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
naming_strategy = 'package.xyz.DatabaseNamingStrategy'
reload = false
}

Error : Unparseable date: "date.struct" with Grails POST/save request

Hi,

the plugin's JSONDateBinder hooked in via CustomEditorRegistrar tries to parse Date values from domain classes and fails to do so:

Even though that the domain class in question is not marked as searchable and a simple controller/service not related to the plugin is being used to save a domain instance, JSONDateBinder.setAsText is being run.

Grails (default) behaviour is to split a Date in a POST/save request to for example:

dueDate:date.struct
dueDate_day:19
dueDate_month:12
dueDate_year:2014

The plugin will try to parse the string "date.struct" as a Date and fail, leaving the value of dueDate equaling to null - which in our case prevents us from saving the instance as the field is not nullable.

Best, Szymon

Grails: 2.3.9
Plugin versions: 0.0.3.7, 0.0.3.8

Log from plugin:

Date date.struct did not match any of the pattern registered! You may want to add the pattern to the [elasticSearch.date.formats] setting.
Error : Unparseable date: "date.struct"

Cannot compile app with plugin version 0.0.3.1 on Grails v.2.3.4

I'm getting a whole stream of 'unable to resolve class ...' type errors when I try to run my app.
These include:

  • org.elasticsearch.action.support.broadcast.BroadcastOperationResponse
  • org.elasticsearch.client.Requests
  • org.elasticsearch.client.Client
  • org.elasticsearch.action.search.SearchRequest
    and so on.

Not using Hibernate 4, pretty sure I've got a standard config.

Any thoughts?

Unexpected behavior (probably a bug)

I have some large collections of objects (more than 50 000 in each collection) indexed by Elastichsearch (via Grails Plugin). The problem is that some of these objects are not being indexed properly by the plugin (Domainclass.index () or bulkIndexOnStartup). After successive runs of the indexing process these objects are being indexed (or after performing an explicit indexing on the object - object.index ()).

No exception is reported during the process. I performed some tests directly on the Elastichsearch Client, searching objects by ID and in fact they are not indexed.

Someone has reported this type of behavior and how to handle it?

I believe it would be useful to have some plugin mechanism for consistency checking to detect possible failures, even using heavy operations, such as checking for each object of a given domain class if it is in ElasticSearch index.

Support of embedded properties?

Having some problems getting embedded properties to work properly. Getting an exception thrown at SearchableClassPropertyMapping.groovy:137. (Property [property] is mapped as component, but dependent mapping is not injected.) when component is set to true. Otherwise it tries to map the property as a String.

Doesn't seem to be any support for this, is there a workaround or is it work in progress?

Support for GeoPoint in domain classes?

It would be nice to have basic support for geopoint in searchable closure. A lot of forks of the original plugin already have that and it seems to be more or less a 3 liner.

One if clause in SearchableClassPropertyMapping and two in ElasticSearchMappingFactory. You can have a look at the "fork" I have in my account.

This simple solution works for String encoded geopoints ("{lat},{lon}").

Datingcafe https://github.com/datingcafe/elasticsearch-gorm-plugin have a solution which works with an embedded Location object.

It would be great to have this in the official plugins.

Unsafe use of SimpleTypeConverter in DomainClassUnmarshaller

I have an application which makes three simultaneous requests to the ElasticSearchService. These requests are faced with an intermittent bug where the id's of some of the results would get mixed up (objects would have the wrong id). After a good bit of investigation, I have determined that the cause is most likely the typeConverter instance variable within DomainClassUnmarshaller. Since DomainClassUnmarshaller is a singleton, and it instantiates this variable with a SimpleTypeConverter at construction, there is a single instance of SimpleTypeConverter shared between all threads of the application.

If you look at the documentation for SimpleTypeConverter here http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/beans/SimpleTypeConverter.html you will see that it is not thread safe. Therefore I recommend removing the typeConverter instance variable in favor of local variables within each method that needs it.

Issue with embedded classes in MongoDB

Hello,

I am using MongoDB. I have a domain class 'Product' which I wish to search. This class has embedded collection of classes "Image". Below is the structure of the classes. They are in same groovy file BTW. Upon running I get the error given at the end of this message. Please guide what am I doing wrong.

class Product {

ObjectId id // For compatibility with MongoDB BSON ObjectId
static mapWith = "mongo" // Store in Mongo rather than local DB

static searchable = { 
    except = ['categories','subcategories']
    images component:true
    videos component:true
    }

static hasMany = [categories:Category,subcategories:SubCategory]

static embedded = ['images', 'videos']

// Attributes
ProductStatusEnum status = 'REVIEW'
Map attributes
Date dateCreated
Date lastUpdated

static constraints = {
}

}

class Image {

static searchable = {
    product parent:true,component:true
}

Product product
String path = ''
String name = ''
String fullPath = ''
String source = ''
ImageViewTypeEnum angle = 'FRONT'
Integer width = 0
Integer height = 0
Boolean resampled = false
Boolean original = true

}

class Video{

static searchable = {
    product parent:true,component:true
}
Product product
String youTubeId = ''
String source = ''

}

Error |
2014-12-23 18:07:45,780 [localhost-startStop-1] ERROR context.GrailsContextLoade
rListener - Error initializing the application: Error creating bean with name '
searchableClassMappingConfigurator': Invocation of init method failed; nested ex
ception is java.lang.IllegalArgumentException: Property images is mapped as comp
onent, but dependent mapping is not injected.
Message: Error creating bean with name 'searchableClassMappingConfigurator': Inv
ocation of init method failed; nested exception is java.lang.IllegalArgumentExce
ption: Property images is mapped as component, but dependent mapping is not inje
cted.
Line | Method
->> 266 | run in java.util.concurrent.FutureTask


| 1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 617 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by IllegalArgumentException: Property images is mapped as component, but
dependent mapping is not injected.
->> 137 | validate in org.grails.plugins.elasticsearch.mapping.SearchableClass
PropertyMapping


| 70 | validate in org.grails.plugins.elasticsearch.mapping.SearchableClass
Mapping
| 78 | mappings in org.grails.plugins.elasticsearch.mapping.SearchableClass
MappingConfigurator
| 50 | configureAndInstallMappings in ''
| 266 | run . . . in java.util.concurrent.FutureTask
| 1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 617 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
| Error Forked Grails VM exited with error

This plugin does not work with Grails 2.3.2

I got this errors while run-app

Caused by BeanCreationException: Error creating bean with name 'elasticSearchClient': FactoryBean threw exception on object creation; nested exception is java.lang.NoClassDefFoundError: org/apache/lucene/util/Version

Elasticsearch Merge Issues

Firstly, thank you for developing this plugin. It is very useful.

After upgrading to Elasticsearch plugin 0.0.3.6. We are getting merge exception, every-time we do run-app. This happens even when have disabled elasticsearch.index is disabled in bootstrap.groovy.

This is the case with plugin version 0.0.3.3

We are using:
Elastic Search Server 1.4.0
Grails 2.4.3
Tomcat Plugin build ":tomcat:8.0.14"

Settings in config.groovy
elasticSearch.datastoreImpl = 'mongoDatastore'
elasticSearch.client.mode = 'transport'
elasticSearch.bulkIndexOnStartup = false

Any pointers will be very helpful.

BigDecimal columns are not mapped well

I have seen a related issue in the original elasticsearch plugin:

mstein#43

The BigDecimal columns are mapped as object, and then cause a problem when it looks like the other way around it fails when unmarshalling a BigDecimal field.

This does not seem to have been addressed yet, despite a pull request that suggests otherwise here:

elastic/elasticsearch#2188

This is old old stuff (1 year) I can't believe that this has not been addressed yet.

I am totally willing to do whatever work needs to be done in the plugin to make it behave on our side, if it has indeed been fixed on the ES side.

Making Bigdecimal fields not searchable seems like a drastic workaround. Anyone has a suggestion?

Allow field aliases

While trying to embed Kibana into my grails app with this plugin the functionality is there.

I noticed though that Kibana is expecting an "@timestamp" field to do filters on its native controls.

It would be awesome to add another option to the searchable closure suchas

static searchable = {
        myField alias:'@timestamp'
    }

I'll look into it, since I am not really sure how elasticsearch treats those fields in the first place.

let the mapping property name be configurable

we're creating grails plugin which should allow users to pick their own search plugin support and we want to provide integration with your plugin out of the box. we would like to declare the mappings in our domain classes but we don't want to use static searchable = ... property for this purpose, because other search plugins uses the same name. would be great if we can change the default property name to something like static elasticGormSearchable = ... so it won't conflict anymore and we can provide mapping for the old searchable plugin as well.

if making the property name configurable is way to much work would be nice if you provide few fallback aliases for that property out of box if the searchable property is not found on the domain class.

Easy nested query example

Hi I was trying to get this working in different ways but I could not.
This is the model:

class Conversation {
    static searchable = {
        root true
        messages component: true
    }
    static hasMany = [messages: Message]
}

class Message {
    def from
    def to
    static searchable = {
        root false
        except = ['conversation']
    }
    static belongsTo = [conversacion: Conversacion]
}

Now I need to get all Conversation where messages.to or messages.from , at least one , are equals to a param.

Conversacion.search(searchType: 'dfs_query_and_fetch') {
    bool {
        should {
            term("messages.from", "[email protected]")
            term("messages.to", "[email protected]")
        }
        minimum_should_match: 1
    }
}

Obviously, it does not work. Have you got any approach to tackle this ?
thanks in advance

LazyInitializationException when saving a entity

Hi! Im my system, I have a job that start some threads to update entitys and in some entitys elasticsearch plugin is throwing a LazyInitializationException like the log below. Any ideas what could cause this? My guess is that other thread is closing that session before IndexRequestQueue realize the marshall of the instance. Is there a way to force IndexRequestQueue to start a new session if the session is allready closed?

Thanks very mutch.

2014-10-15 19:28:34,360 [elasticsearch[Uatu][transport_client_worker][T#4]{New I/O worker #4}] ERROR index.IndexRequestQueue  - Error Indexing class br.com.fofertas.Produto (index: br.com.fofertas , type: produto) of id 67379
Message: Failed to marshall domain instance [Produto: Macacรฃo Baby Natural Zig Mundi]
    Line | Method
->>  107 | toJSON                       in org.grails.plugins.elasticsearch.index.IndexRequestQueue
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    148 | doCall                       in org.grails.plugins.elasticsearch.index.IndexRequestQueue$_executeRequests_closure1
|    142 | executeRequests . . . . . .  in org.grails.plugins.elasticsearch.index.IndexRequestQueue
|    322 | push                         in org.grails.plugins.elasticsearch.index.IndexRequestQueue$OperationBatch
|    281 | onResponse . . . . . . . . . in     ''
|    131 | executeListener              in org.elasticsearch.action.support.AbstractListenableActionFuture
|    103 | done . . . . . . . . . . . . in     ''
|    162 | set                          in org.elasticsearch.common.util.concurrent.BaseFuture
|     98 | onResponse . . . . . . . . . in org.elasticsearch.action.support.AdapterActionFuture
|    338 | finishHim                    in org.elasticsearch.action.bulk.TransportBulkAction$2
|    308 | onResponse . . . . . . . . . in     ''
|    301 | onResponse                   in     ''
|    462 | handleResponse . . . . . . . in org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$2
|    448 | handleResponse               in     ''
|    158 | handleResponse . . . . . . . in org.elasticsearch.transport.netty.MessageChannelHandler
|    127 | messageReceived              in     ''
|     70 | handleUpstream . . . . . . . in org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler
|    564 | sendUpstream                 in org.elasticsearch.common.netty.channel.DefaultChannelPipeline
|    791 | sendUpstream . . . . . . . . in org.elasticsearch.common.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext
|    296 | fireMessageReceived          in org.elasticsearch.common.netty.channel.Channels
|    462 | unfoldAndFireMessageReceived in org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder
|    443 | callDecode                   in     ''
|    303 | messageReceived . . . . . .  in     ''
|     70 | handleUpstream               in org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler
|    564 | sendUpstream . . . . . . . . in org.elasticsearch.common.netty.channel.DefaultChannelPipeline
|    559 | sendUpstream                 in     ''
|    268 | fireMessageReceived . . . .  in org.elasticsearch.common.netty.channel.Channels
|    255 | fireMessageReceived          in     ''
|     88 | read . . . . . . . . . . . . in org.elasticsearch.common.netty.channel.socket.nio.NioWorker
|    108 | process                      in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker
|    318 | run . . . . . . . . . . . .  in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector
|     89 | run                          in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker
|    178 | run . . . . . . . . . . . .  in org.elasticsearch.common.netty.channel.socket.nio.NioWorker
|    108 | run                          in org.elasticsearch.common.netty.util.ThreadRenamingRunnable
|     42 | run . . . . . . . . . . . .  in org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1
|   1145 | runWorker                    in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . . . . . . . .  in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run                          in java.lang.Thread
Caused by LazyInitializationException: could not initialize proxy - no Session
->>  150 | doCall                       in org.grails.plugins.elasticsearch.conversion.JSONDomainFactory$_buildJSON_closure3
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    148 | buildJSON                    in org.grails.plugins.elasticsearch.conversion.JSONDomainFactory
|    105 | toJSON . . . . . . . . . . . in org.grails.plugins.elasticsearch.index.IndexRequestQueue
|    148 | doCall                       in org.grails.plugins.elasticsearch.index.IndexRequestQueue$_executeRequests_closure1
|    142 | executeRequests . . . . . .  in org.grails.plugins.elasticsearch.index.IndexRequestQueue
|    322 | push                         in org.grails.plugins.elasticsearch.index.IndexRequestQueue$OperationBatch
|    281 | onResponse . . . . . . . . . in     ''
|    131 | executeListener              in org.elasticsearch.action.support.AbstractListenableActionFuture
|    103 | done . . . . . . . . . . . . in     ''
|    162 | set                          in org.elasticsearch.common.util.concurrent.BaseFuture
|     98 | onResponse . . . . . . . . . in org.elasticsearch.action.support.AdapterActionFuture
|    338 | finishHim                    in org.elasticsearch.action.bulk.TransportBulkAction$2
|    308 | onResponse . . . . . . . . . in     ''
|    301 | onResponse                   in     ''
|    462 | handleResponse . . . . . . . in org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$2
|    448 | handleResponse               in     ''
|    158 | handleResponse . . . . . . . in org.elasticsearch.transport.netty.MessageChannelHandler
|    127 | messageReceived              in     ''
|     70 | handleUpstream . . . . . . . in org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler
|    564 | sendUpstream                 in org.elasticsearch.common.netty.channel.DefaultChannelPipeline
|    791 | sendUpstream . . . . . . . . in org.elasticsearch.common.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext
|    296 | fireMessageReceived          in org.elasticsearch.common.netty.channel.Channels
|    462 | unfoldAndFireMessageReceived in org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder
|    443 | callDecode                   in     ''
|    303 | messageReceived . . . . . .  in     ''
|     70 | handleUpstream               in org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler
|    564 | sendUpstream . . . . . . . . in org.elasticsearch.common.netty.channel.DefaultChannelPipeline
|    559 | sendUpstream                 in     ''
|    268 | fireMessageReceived . . . .  in org.elasticsearch.common.netty.channel.Channels
|    255 | fireMessageReceived          in     ''
|     88 | read . . . . . . . . . . . . in org.elasticsearch.common.netty.channel.socket.nio.NioWorker
|    108 | process                      in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker
|    318 | run . . . . . . . . . . . .  in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector
|     89 | run                          in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker
|    178 | run . . . . . . . . . . . .  in org.elasticsearch.common.netty.channel.socket.nio.NioWorker
|    108 | run                          in org.elasticsearch.common.netty.util.ThreadRenamingRunnable
|     42 | run . . . . . . . . . . . .  in org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1
|   1145 | runWorker                    in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . . . . . . . .  in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run                          in java.lang.Thread

failed to process cluster event (put-mapping [event]) within 30s

Forked Grails 2.3.7

BuildConfig:

grails.project.fork = [
        // configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required
        //  compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],

        // configure settings for the test-app JVM, uses the daemon by default
        test   : [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon: true],
        // test   : false,

        // configure settings for the run-app JVM
        run    : [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve: false],
        // run    : false,

        // configure settings for the run-war JVM
        war    : [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve: false],

        // configure settings for the Console UI JVM
        console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
]
// ...
dependencies {
    plugins {
        // ...
        compile ':elasticsearch:0.0.2.5'
    }
}

Config:

elasticSearch {
    datastoreImpl = 'mongoDatastore'

    bulkIndexOnStartup = false
}

Lib:
elasticsearch-0.90.5.jar (by default)

Error when run app:

| Error 2014-04-06 14:30:21,194 [localhost-startStop-1] ERROR context.GrailsContextLoader  - Error initializing the application: Error creating bean with name 'searchableClassMappingConfigurator': Invocation of init method failed; nested exception is org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException: failed to process cluster event (put-mapping [event]) within 30s
Message: Error creating bean with name 'searchableClassMappingConfigurator': Invocation of init method failed; nested exception is org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException: failed to process cluster event (put-mapping [event]) within 30s
    Line | Method
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run       in java.lang.Thread
Caused by ProcessClusterEventTimeoutException: failed to process cluster event (put-mapping [event]) within 30s
->>  237 | run       in org.elasticsearch.cluster.service.InternalClusterService$2$1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run       in java.lang.Thread
| Error Forked Grails VM exited with error

Support for indexing transient properties ?

Transient properties if supported, can help in reducing the mapping complexity and give a great handle on keeping the mapping of indices cleaner, without making all of the other domain classes searchable.
e.g User has Rating, where Rating is transient & is fetched through a service, as rating is necessarily calculated as average of all available ratings.
I tried the approach mentioned here :
mstein#17

But I have hit a roadblock, it seems a valid hibernateSession + service dependecy Injection is required inside the scope of plugin.
As soon as my transient property is reached, I get this error

| Error 2014-06-12 22:52:08,238 [localhost-startStop-1] ERROR hibernate.AssertionFailure  - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
Message: null id in User entry (don't flush the Session after an exception occurs)
    Line | Method
->>   70 | getRating                      in User

Any help would be great.

java.lang.NullPointerException: Cannot get property 'entity' on null object

An exception is raised when saving domain objects :
It happens in different contexts : services, controllers

| Error 2013-11-24 23:10:30,658 [http-bio-8080-exec-2] ERROR errors.GrailsExceptionResolver  - NullPointerException occurred when processing request: [GET] /admin/testeuh
Cannot get property 'entity' on null object. Stacktrace follows:
Message: Cannot get property 'entity' on null object
    Line | Method
->>  126 | onPostInsert         in org.grails.plugins.elasticsearch.AuditEventListener
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    112 | onPersistenceEvent   in     ''
|     47 | onApplicationEvent . in org.grails.datastore.mapping.engine.event.AbstractPersistenceEventListener
|     67 | beforeValidate       in app.Enterprise
|    153 | call . . . . . . . . in org.grails.datastore.gorm.support.EventTriggerCaller$MethodCaller
|     96 | call                 in org.grails.datastore.gorm.support.EventTriggerCaller
|     44 | call . . . . . . . . in org.grails.datastore.gorm.support.BeforeValidateHelper$BeforeValidateEventTriggerCaller
|     56 | invokeBeforeValidate in org.grails.datastore.gorm.support.BeforeValidateHelper
|     47 | onApplicationEvent . in org.grails.datastore.mapping.engine.event.AbstractPersistenceEventListener
|     33 | testeuh              in util.admin.AdminController$$EOO9Lj20
|    195 | doFilter . . . . . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
|     63 | doFilter             in grails.plugin.cache.web.filter.AbstractFilter
|   1110 | runWorker . . . . .  in java.util.concurrent.ThreadPoolExecutor
|    603 | run                  in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . . . . . .  in java.lang.Thread

I am under grails 2.3.3.

Any idea ?

Implement the unicode collation algorithm sorting

elasticsearch has a pretty cool feature that enables to sort strings alphabetically using the Unicode Collation Algorithm. See the docs.

Unfortunately, this isn't actually available in the plugin, it is currently only possible to have a lexicographical order (order by the characters' bytes values).

Are there plans to include this in a future version of the plugin?

java.lang.IllegalStateException while loading ApplicationContext duting Integration tests start up

Hi,

We are using grails 2.4.4 and the elastic search plugin 0.0.3.7.

When we try to run the integration tests phase grails test-app integration: --stacktrace, during start up, right before running any tests we get the following error:

| Error Fatal error running tests: Error creating bean with name 'searchableClassMappingConfigurator': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Could not find ApplicationContext, configure Grails correctly first (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'searchableClassMappingConfigurator': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Could not find ApplicationContext, configure Grails correctly first
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1554)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:706)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    at _GrailsTest$_run_closure1.doCall(_GrailsTest.groovy:102)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
    at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at TestApp$_run_closure1.doCall(TestApp.groovy:32)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
    at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
    at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
    at gant.Gant.withBuildListeners(Gant.groovy:427)
    at gant.Gant.this$2$withBuildListeners(Gant.groovy)
    at gant.Gant$this$2$withBuildListeners$0.callCurrent(Unknown Source)
    at gant.Gant.dispatch(Gant.groovy:415)
    at gant.Gant.this$2$dispatch(Gant.groovy)
    at gant.Gant.invokeMethod(Gant.groovy)
    at gant.Gant.executeTargets(Gant.groovy:591)
    at gant.Gant.executeTargets(Gant.groovy:590)
Caused by: java.lang.IllegalStateException: Could not find ApplicationContext, configure Grails correctly first
    at grails.util.Holders.getApplicationContext(Holders.java:97)
    at org.grails.plugins.elasticsearch.mapping.ElasticSearchMappingFactory.treatValueAsAString(ElasticSearchMappingFactory.groovy:180)
    at org.grails.plugins.elasticsearch.mapping.ElasticSearchMappingFactory$_getMappingProperties_closure2.doCall(ElasticSearchMappingFactory.groovy:136)
    at org.grails.plugins.elasticsearch.mapping.ElasticSearchMappingFactory.getMappingProperties(ElasticSearchMappingFactory.groovy:67)
    at org.grails.plugins.elasticsearch.mapping.ElasticSearchMappingFactory.getElasticMapping(ElasticSearchMappingFactory.groovy:47)
    at org.grails.plugins.elasticsearch.mapping.ElasticSearchMappingFactory$_getMappingProperties_closure2.doCall(ElasticSearchMappingFactory.groovy:120)
    at org.grails.plugins.elasticsearch.mapping.ElasticSearchMappingFactory.getMappingProperties(ElasticSearchMappingFactory.groovy:67)
    at org.grails.plugins.elasticsearch.mapping.ElasticSearchMappingFactory.getElasticMapping(ElasticSearchMappingFactory.groovy:47)
    at org.grails.plugins.elasticsearch.mapping.ElasticSearchMappingFactory$getElasticMapping.call(Unknown Source)
    at org.grails.plugins.elasticsearch.mapping.SearchableClassMappingConfigurator.installMappings(SearchableClassMappingConfigurator.groovy:108)
    at org.grails.plugins.elasticsearch.mapping.SearchableClassMappingConfigurator$installMappings.callCurrent(Unknown Source)
    at org.grails.plugins.elasticsearch.mapping.SearchableClassMappingConfigurator.configureAndInstallMappings(SearchableClassMappingConfigurator.groovy:51)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1682)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1621)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1550)
    ... 37 more
| Error Fatal error running tests: Error creating bean with name 'searchableClassMappingConfigurator': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Could not find ApplicationContext, configure Grails correctly first
| Tests FAILED  - view reports in /Users/marcoscarceles/dev/projects/endource/target/test-reports
| Error Error executing script TestApp: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'searchableClassMappingConfigurator': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Could not find ApplicationContext, configure Grails correctly first (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'searchableClassMappingConfigurator': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Could not find ApplicationContext, configure Grails correctly first
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1554)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:706)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    at _GrailsTest$_run_closure1.doCall(_GrailsTest.groovy:102)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
    at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at TestApp$_run_closure1.doCall(TestApp.groovy:32)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
    at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
    at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
    at gant.Gant.withBuildListeners(Gant.groovy:427)
    at gant.Gant.this$2$withBuildListeners(Gant.groovy)
    at gant.Gant$this$2$withBuildListeners$0.callCurrent(Unknown Source)
    at gant.Gant.dispatch(Gant.groovy:415)
    at gant.Gant.this$2$dispatch(Gant.groovy)
    at gant.Gant.invokeMethod(Gant.groovy)
    at gant.Gant.executeTargets(Gant.groovy:591)
    at gant.Gant.executeTargets(Gant.groovy:590)
Caused by: java.lang.IllegalStateException: Could not find ApplicationContext, configure Grails correctly first
    at grails.util.Holders.getApplicationContext(Holders.java:97)
    at org.grails.plugins.elasticsearch.mapping.ElasticSearchMappingFactory.treatValueAsAString(ElasticSearchMappingFactory.groovy:180)
    at org.grails.plugins.elasticsearch.mapping.ElasticSearchMappingFactory$_getMappingProperties_closure2.doCall(ElasticSearchMappingFactory.groovy:136)
    at org.grails.plugins.elasticsearch.mapping.ElasticSearchMappingFactory.getMappingProperties(ElasticSearchMappingFactory.groovy:67)
    at org.grails.plugins.elasticsearch.mapping.ElasticSearchMappingFactory.getElasticMapping(ElasticSearchMappingFactory.groovy:47)
    at org.grails.plugins.elasticsearch.mapping.ElasticSearchMappingFactory$_getMappingProperties_closure2.doCall(ElasticSearchMappingFactory.groovy:120)
    at org.grails.plugins.elasticsearch.mapping.ElasticSearchMappingFactory.getMappingProperties(ElasticSearchMappingFactory.groovy:67)
    at org.grails.plugins.elasticsearch.mapping.ElasticSearchMappingFactory.getElasticMapping(ElasticSearchMappingFactory.groovy:47)
    at org.grails.plugins.elasticsearch.mapping.ElasticSearchMappingFactory$getElasticMapping.call(Unknown Source)
    at org.grails.plugins.elasticsearch.mapping.SearchableClassMappingConfigurator.installMappings(SearchableClassMappingConfigurator.groovy:108)
    at org.grails.plugins.elasticsearch.mapping.SearchableClassMappingConfigurator$installMappings.callCurrent(Unknown Source)
    at org.grails.plugins.elasticsearch.mapping.SearchableClassMappingConfigurator.configureAndInstallMappings(SearchableClassMappingConfigurator.groovy:51)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1682)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1621)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1550)
    ... 37 more
| Error Error executing script TestApp: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'searchableClassMappingConfigurator': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Could not find ApplicationContext, configure Grails correctly first

The error seems to be trying to get access to the applicationContext here:
https://github.com/noamt/elasticsearch-grails-plugin/blob/master/src/groovy/org/grails/plugins/elasticsearch/mapping/ElasticSearchMappingFactory.groovy#L180

This error seems to occur only during integration tests, and not when running the application grails run-app

Support Facet Closue ?

Thanks for upgrading this greate plugin
We used to use searchInJson to post the query json with old plugin.
But i checked the new plugin , in ElasticSearchService , it does not have this method any longer. The SearchRequest buildSearchRequest(query, Closure filter, Map params) does not seem to take Facet Closure as well.

Can you please specify how this plugin can take Facet block

Cheers

Only can add One Sorter

In buildSearchRequest(query, Closure filter, Map params) in ElasticSarch Servince

It only add one sorter( see the following code)

But actually, SearchSourceBuilder source can add multiple sorters

Hope you can fix this small issue

Cheers
Wallace

Example of working many-to-one mapping: get Hibernate error

Can someone provide a working example of a many-to-one mapping? I can't seem to get it right; must be that I've something obvious wrong.

I've got the following example where a User has many Storys, and I'm searching on Story:

Domains:

class Story {

    String text
    String keywords
    Date dateCreated

    static constraints = {
    }

    static belongsTo = [user : User]

    static searchable = {
        user component:true
    }
}

class User {

    String firstname
    String lastname
    Date date_of_birth

    static constraints = {
    }

    static hasMany = [story : Story]

    static searchable = true
}

Controller:

class SearchController {

    static defaultAction = "search"

    def index() { }

    def search = {
        Closure query = {
                            bool {
                                should {
                                    term(text: params.q)
                                }
                                should {
                                    term(keywords: params.q)
                                }
                            }
        }
        //def stories = Story.search(query)
        def stories = Story.search("${params.q}")
        def storyResults = stories.searchResults
        return [searchResult: stories,querystring:params.q]
       }       
}

In the debugger the storyResults looks OK in the I have Users nested in the returns, but when hitting the search endpoint (either using the closure or the query string) I get the error below. It works OK for 1:1 mapping. The data in index seems OK in that it is nested properly and so forth.

ERROR hibernate.AssertionFailure  - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
Message: null id in XXX.Story entry (don't flush the Session after an exception occurs)

Thanks so much!

fields, in serch result, lastUpdated and dateCreated return null values

Hi. I'm using elasticsearch-grails-plugin (elasticsearch: 0.0.3.5) in my project. I created the index:

package elastic.search

class Action {
    String name
    Date createDate = new Date()
    Date deleteDate
    Date lastUpdated
    Date dateCreated
    String notes
    Service service
    User createUser
    static constraints = {
        deleteDate  nullable: true
        service     nullable: true
        createUser  nullable: true
    }
    static searchable = true
}

I'm searching in index:

    def search = {
        def result = []
        def res = elasticSearchService.search("")
        res.searchResults.each {
            if(it instanceof Action) {
                result.add(it)
            }
        }
    }

As a result in "result", fields lastUpdated and dateCreated return null values????

Marshalling fails with NPE

Caused by NullPointerException: Cannot get property 'clazz' on null object
->>   11 | doMarshall                       in org.grails.plugins.elasticsearch.conversion.marshall.DeepDomainClassMarshaller
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|     36 | marshall                         in org.grails.plugins.elasticsearch.conversion.marshall.DefaultMarshaller
|    115 | delegateMarshalling . . . . . .  in org.grails.plugins.elasticsearch.conversion.JSONDomainFactory
|     73 | delegateMarshalling              in org.grails.plugins.elasticsearch.conversion.marshall.DefaultMarshallingContext
|      6 | doCall . . . . . . . . . . . . . in org.grails.plugins.elasticsearch.conversion.marshall.CollectionMarshaller$_doMarshall_closure1
|      5 | doMarshall                       in org.grails.plugins.elasticsearch.conversion.marshall.CollectionMarshaller
|     36 | marshall . . . . . . . . . . . . in org.grails.plugins.elasticsearch.conversion.marshall.DefaultMarshaller
|    115 | delegateMarshalling              in org.grails.plugins.elasticsearch.conversion.JSONDomainFactory
|    138 | doCall . . . . . . . . . . . . . in org.grails.plugins.elasticsearch.conversion.JSONDomainFactory$_buildJSON_closure3
|    136 | buildJSON                        in org.grails.plugins.elasticsearch.conversion.JSONDomainFactory
|    116 | toJSON . . . . . . . . . . . . . in org.grails.plugins.elasticsearch.index.IndexRequestQueue
|    160 | doCall                           in org.grails.plugins.elasticsearch.index.IndexRequestQueue$_executeRequests_closure1
|    153 | executeRequests . . . . . . . .  in org.grails.plugins.elasticsearch.index.IndexRequestQueue
|    246 | doCall                           in org.grails.plugins.elasticsearch.ElasticSearchService$_doBulkRequest_closure2_closure10
|    234 | doCall . . . . . . . . . . . . . in org.grails.plugins.elasticsearch.ElasticSearchService$_doBulkRequest_closure2
|    222 | doBulkRequest                    in org.grails.plugins.elasticsearch.ElasticSearchService
|    129 | index . . . . . . . . . . . . .  in     ''
|    138 | index                            in     ''
|      9 | doCall . . . . . . . . . . . . . in ElasticsearchBootStrap$_closure1
|    308 | evaluateEnvironmentSpecificBlock in grails.util.Environment
|    301 | executeForEnvironment . . . . .  in     ''
|    277 | executeForCurrentEnvironment     in     ''
|    262 | run . . . . . . . . . . . . . .  in java.util.concurrent.FutureTask
|   1145 | runWorker                        in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . . . . . . . . . .  in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run                              in java.lang.Thread

I managed to move forward with this change in org.grails.plugins.elasticsearch.conversion.marshall.DeepDomainClassMarshaller:

private GrailsDomainClass getDomainClass(instance) {
        def instanceClass = GrailsHibernateUtil.unwrapIfProxy(instance).class
        grailsApplication.domainClasses.find { it.clazz == instanceClass }
    }

Original code didn't unwrap javassit proxies correctly. :(

but then I get

Caused by NullPointerException: Cannot get property 'fullName' on null object
->>   56 | getProperty                      in org.codehaus.groovy.runtime.NullObject
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    169 | getProperty                      in org.codehaus.groovy.runtime.InvokerHelper
|     41 | callGetProperty . . . . . . . .  in org.codehaus.groovy.runtime.callsite.PojoMetaClassGetPropertySite
|     -1 | call                             in org.grails.plugins.elasticsearch.ElasticSearchContextHolder$getMappingContext$1
|     45 | defaultCall . . . . . . . . . .  in org.codehaus.groovy.runtime.callsite.CallSiteArray
|     -1 | call                             in org.grails.plugins.elasticsearch.ElasticSearchContextHolder$getMappingContext$1
|     73 | delegateMarshalling . . . . . .  in org.grails.plugins.elasticsearch.conversion.JSONDomainFactory
|     -1 | call                             in org.grails.plugins.elasticsearch.conversion.JSONDomainFactory$delegateMarshalling$1
|     45 | defaultCall . . . . . . . . . .  in org.codehaus.groovy.runtime.callsite.CallSiteArray
|     -1 | call                             in org.grails.plugins.elasticsearch.conversion.JSONDomainFactory$delegateMarshalling$1
|     73 | delegateMarshalling . . . . . .  in org.grails.plugins.elasticsearch.conversion.marshall.DefaultMarshallingContext
|     -1 | delegateMarshalling              in     ''
|     38 | doMarshall . . . . . . . . . . . in org.grails.plugins.elasticsearch.conversion.marshall.DeepDomainClassMarshaller
|     -1 | invoke                           in sun.reflect.GeneratedMethodAccessor376
|     43 | invoke . . . . . . . . . . . . . in sun.reflect.DelegatingMethodAccessorImpl
|    606 | invoke                           in java.lang.reflect.Method
|   1254 | jlrMethodInvoke . . . . . . . .  in org.springsource.loaded.ri.ReflectiveInterceptor
|    272 | invoke                           in org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce
|     52 | callCurrent . . . . . . . . . .  in org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite
|     49 | defaultCallCurrent               in org.codehaus.groovy.runtime.callsite.CallSiteArray
|     57 | callCurrent . . . . . . . . . .  in org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite
|    141 | callCurrent                      in org.codehaus.groovy.runtime.callsite.AbstractCallSite
|     36 | marshall . . . . . . . . . . . . in org.grails.plugins.elasticsearch.conversion.marshall.DefaultMarshaller
|     -1 | marshall                         in org.grails.plugins.elasticsearch.conversion.marshall.DeepDomainClassMarshaller
|     45 | defaultCall . . . . . . . . . .  in org.codehaus.groovy.runtime.callsite.CallSiteArray
|     -1 | call                             in org.grails.plugins.elasticsearch.conversion.marshall.Marshaller$marshall
|    115 | delegateMarshalling . . . . . .  in org.grails.plugins.elasticsearch.conversion.JSONDomainFactory
|     -1 | call                             in org.grails.plugins.elasticsearch.conversion.JSONDomainFactory$delegateMarshalling$1
|     45 | defaultCall . . . . . . . . . .  in org.codehaus.groovy.runtime.callsite.CallSiteArray
|     -1 | call                             in org.grails.plugins.elasticsearch.conversion.JSONDomainFactory$delegateMarshalling$1
|     73 | delegateMarshalling . . . . . .  in org.grails.plugins.elasticsearch.conversion.marshall.DefaultMarshallingContext
|     -1 | delegateMarshalling              in     ''
|      6 | doCall . . . . . . . . . . . . . in org.grails.plugins.elasticsearch.conversion.marshall.CollectionMarshaller$_doMarshall_closure1
|     -1 | invoke                           in sun.reflect.GeneratedMethodAccessor375
|     43 | invoke . . . . . . . . . . . . . in sun.reflect.DelegatingMethodAccessorImpl
|    606 | invoke                           in java.lang.reflect.Method
|   1254 | jlrMethodInvoke . . . . . . . .  in org.springsource.loaded.ri.ReflectiveInterceptor
|     90 | invoke                           in org.codehaus.groovy.reflection.CachedMethod
|    233 | doMethodInvoke . . . . . . . . . in groovy.lang.MetaMethod
|   1086 | invokeMethod                     in groovy.lang.MetaClassImpl
|   1110 | invokeMethod . . . . . . . . . . in groovy.lang.ExpandoMetaClass
|    910 | invokeMethod                     in groovy.lang.MetaClassImpl
|    411 | call . . . . . . . . . . . . . . in groovy.lang.Closure
(...)

Allow getIndexName() to be overridden

We have a requirement in our application where we index each domain separately and the index name should reflect the domain's identifiable name. Let me take a hypothetical example of dropbox for brevity. Every dropbox account user has a username to identify it. In my application, this "username" will become my index name. The domain Dropbox has a hasMany relation with Files and Folders. Files and Folders are the actual data that I am planning to index.

All I want to do is to simply assign the index name and index the data for that particular user. The index name keeps changing for every user. So all data is not concentrated at one place.

The getIndexName() method in SearchableClassMapping is the obvious candidate for overriding. But I am unable to do that because this is essentially a singleton class wrapped in a context.

Can someone suggest a workaround?

Error while adding plugin to an existing Grails Project

Hello,

Please help me resolve the following issue. I am unable to start the plugin in my grails project.

I am on Grails 2.4.3,
I have installed Elasticsearch 1.4.2 on my Windows machine
I am using MongoDB and I have Grails MongoDB plugin compile ":mongodb:3.0.2" in BuildConfig
I am in development mode.
I installed the plugin by adding runtime ':elasticsearch:0.0.3.8' to BuildConfig.groovy.
I have added following lines in config.groovy to tell ElasticSearch plugin that I am using MongoDB
elasticSearch {
datastoreImpl = 'mongoDatastore'
}
I have also set the environment variable ELASTIC_SEARCH_HOME in my system

Rest of the Elasticsearch plugin config is assumed to be default

I have not added an static mapping to any domain as yet..

Now, I run "grails run-app" and I get the following error.

Error |
2014-12-21 14:29:49,230 [localhost-startStop-1] ERROR context.GrailsContextLoad
rListener - Error initializing the application: Error creating bean with name
searchableClassMappingConfigurator': Invocation of init method failed; nested e
ception is java.lang.IllegalArgumentException: 'searchable' property has unknow
type: class org.codehaus.groovy.runtime.NullObject
Message: Error creating bean with name 'searchableClassMappingConfigurator': In
ocation of init method failed; nested exception is java.lang.IllegalArgumentExc
ption: 'searchable' property has unknown type: class org.codehaus.groovy.runtim
.NullObject
Line | Method
->> 266 | run in java.util.concurrent.FutureTask


| 1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 617 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by IllegalArgumentException: 'searchable' property has unknown type: cla
s org.codehaus.groovy.runtime.NullObject
->> 139 | buildClassMapping in org.grails.plugins.elasticsearch.mapping.Search
bleDomainClassMapper


| 59 | mappings in org.grails.plugins.elasticsearch.mapping.SearchableClas
MappingConfigurator
| 50 | configureAndInstallMappings in ''
| 266 | run in java.util.concurrent.FutureTask
| 1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 617 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run . . . in java.lang.Thread
| Error Forked Grails VM exited with error

intellij 13 startup issues...

When trying to debug in grails 2.3.4 using the 0.2.2 release of this plugin, I get traces like the one below.

It's indicating something about "java.lang.NoClassDefFoundError: org/quartz/DisallowConcurrentExecution"

I don't have quartz installed for this project, it's not a requirement for the project and isn't listed as a dependency on this plugin (or is it?).

What's stranger is that this works when I just 'run-app', but ... then I can't debug. This all works just fine in IntelliJ 13 before I started trying to use the elasticsearch-gorm-plugin.

Any insight? A config I'm missing?

/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/Home/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:59380,suspend=y,server=n -Dgrails.home=/Users/michael/gvm/grails/2.3.4 -Dbase.dir=/Users/michael/work/grails/kl3 -Dtools.jar=/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/Home/lib/tools.jar -Dgroovy.starter.conf=/Users/michael/gvm/grails/2.3.4/conf/groovy-starter.conf -Xmx768M -Xms768M -XX:MaxPermSize=256m -XX:PermSize=256m -javaagent:/Users/michael/gvm/grails/2.3.4/lib/org.springsource.springloaded/springloaded-core/jars/springloaded-core-1.1.4.jar -noverify -Dspringloaded=profile=grails -Dfile.encoding=UTF-8 -classpath "/Users/michael/gvm/grails/2.3.4/lib/org.codehaus.groovy/groovy-all/jars/groovy-all-2.1.9.jar:/Users/michael/gvm/grails/2.3.4/dist/grails-bootstrap-2.3.4.jar:/Applications/IntelliJ IDEA 13 EAP.app/lib/idea_rt.jar" org.codehaus.groovy.grails.cli.support.GrailsStarter --main org.codehaus.groovy.grails.cli.GrailsScriptRunner --conf /Users/michael/gvm/grails/2.3.4/conf/groovy-starter.conf "run-app --verbose --stacktrace"
Connected to the target VM, address: '127.0.0.1:59380', transport: 'socket'
Base Directory: /Users/michael/work/grails/kl3
| Loading Grails 2.3.4
| Configuring classpath
| Configuring classpath.
| Environment set to development
| Environment set to development.
| Environment set to development..
| Environment set to development...
| Environment set to development....
| Environment set to development.....
| Packaging Grails application
| Packaging Grails application.
| Packaging Grails application..
| Packaging Grails application...
| Packaging Grails application....
| Packaging Grails application.....
| Running Grails application

Configuring Spring Security Core ...
... finished configuring Spring Security Core

Configuring Spring Security UI ...
... finished configuring Spring Security UI
| Error 2014-02-01 15:28:07,547 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: Error creating bean with name 'searchableClassMappingConfigurator': Cannot resolve reference to bean 'elasticSearchClient' while setting bean property 'elasticSearchClient'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elasticSearchClient': FactoryBean threw exception on object creation; nested exception is org.elasticsearch.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: org/quartz/DisallowConcurrentExecution

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'searchableClassMappingConfigurator': Cannot resolve reference to bean 'elasticSearchClient' while setting bean property 'elasticSearchClient'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elasticSearchClient': FactoryBean threw exception on object creation; nested exception is org.elasticsearch.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: org/quartz/DisallowConcurrentExecution
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1417)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1158)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.codehaus.groovy.grails.commons.spring.ReloadAwareAutowireCapableBeanFactory.doCreateBean(ReloadAwareAutowireCapableBeanFactory.java:127)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.codehaus.groovy.grails.commons.spring.DefaultRuntimeSpringConfiguration.getApplicationContext(DefaultRuntimeSpringConfiguration.java:153)
at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:169)
at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:127)
at org.codehaus.groovy.grails.web.context.GrailsConfigUtils.configureWebApplicationContext(GrailsConfigUtils.java:122)
at org.codehaus.groovy.grails.web.context.GrailsContextLoader.initWebApplicationContext(GrailsContextLoader.java:108)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elasticSearchClient': FactoryBean threw exception on object creation; nested exception is org.elasticsearch.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: org/quartz/DisallowConcurrentExecution
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1468)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:307)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323)
... 29 more
Caused by: org.elasticsearch.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: org/quartz/DisallowConcurrentExecution
at org.elasticsearch.common.cache.LocalCache$Segment.get(LocalCache.java:2197)
at org.elasticsearch.common.cache.LocalCache.get(LocalCache.java:3932)
at org.elasticsearch.common.cache.LocalCache.getOrLoad(LocalCache.java:3936)
at org.elasticsearch.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4806)
at org.elasticsearch.common.inject.internal.FailableCache.get(FailableCache.java:51)
at org.elasticsearch.common.inject.ConstructorInjectorStore.get(ConstructorInjectorStore.java:50)
at org.elasticsearch.common.inject.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:50)
at org.elasticsearch.common.inject.InjectorImpl.initializeBinding(InjectorImpl.java:372)
at org.elasticsearch.common.inject.BindingProcessor$1$1.run(BindingProcessor.java:148)
at org.elasticsearch.common.inject.BindingProcessor.initializeBindings(BindingProcessor.java:204)
at org.elasticsearch.common.inject.InjectorBuilder.initializeStatically(InjectorBuilder.java:119)
at org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java:102)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:93)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:70)
at org.elasticsearch.common.inject.ModulesBuilder.createInjector(ModulesBuilder.java:59)
at org.elasticsearch.node.internal.InternalNode.(InternalNode.java:171)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:159)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:166)
at org.elasticsearch.node.NodeBuilder$node$1.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at org.grails.plugins.elasticsearch.ClientNodeFactoryBean.getObject(ClientNodeFactoryBean.groovy:145)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
... 34 more
Caused by: java.lang.NoClassDefFoundError: org/quartz/DisallowConcurrentExecution
at java.lang.reflect.Proxy.defineClass0(Native Method)
at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:636)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:713)
at sun.reflect.annotation.AnnotationParser.annotationForMap(AnnotationParser.java:258)
at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:248)
at sun.reflect.annotation.AnnotationParser.parseParameterAnnotations2(AnnotationParser.java:152)
at sun.reflect.annotation.AnnotationParser.parseParameterAnnotations(AnnotationParser.java:129)
at java.lang.reflect.Constructor.getParameterAnnotations(Constructor.java:658)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrConstructorGetParameterAnnotations(ReflectiveInterceptor.java:1437)
at org.elasticsearch.common.inject.spi.InjectionPoint.(InjectionPoint.java:67)
at org.elasticsearch.common.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.java:196)
at org.elasticsearch.common.inject.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:59)
at org.elasticsearch.common.inject.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:29)
at org.elasticsearch.common.inject.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:37)
at org.elasticsearch.common.inject.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:33)
at org.elasticsearch.common.inject.internal.FailableCache$1.load(FailableCache.java:39)
at org.elasticsearch.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3522)
at org.elasticsearch.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2315)
at org.elasticsearch.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2278)
at org.elasticsearch.common.cache.LocalCache$Segment.get(LocalCache.java:2193)
... 57 more
Caused by: java.lang.ClassNotFoundException: org.quartz.DisallowConcurrentExecution
at org.codehaus.groovy.tools.RootLoader.findClass(RootLoader.java:175)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:147)
at org.codehaus.groovy.grails.cli.support.GrailsRootLoader.loadClass(GrailsRootLoader.java:51)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 77 more
Disconnected from the target VM, address: '127.0.0.1:59380', transport: 'socket'

Process finished with exit code 1

Integration tests break because of problem in doWithSpring with fix

Hi there, integration tests throw an NPE because application.parentContext is null in the doWithSpring closure. The fix is quite easy (after a good time hunting it down :P)

Replace:

    def pluginManager =  application.parentContext.getBean(GrailsPluginManager.BEAN_NAME)
    if (((GrailsPluginManager) pluginManager).hasGrailsPlugin('hibernate')) {
        hibernateProxyUnWrapper(HibernateProxyUnWrapper)
    } 

With:
if(manager?.hasGrailsPlugin('hibernate')) {
hibernateProxyUnWrapper(HibernateProxyUnWrapper)
}

GrailsPluginManager obviously gets injected as manager. The fix is taken from the JCR plugin.

Indexing Performance

I have MySql DB with less than 3000 rows in total for all my 20 tables combined.
Elastic search on startup is running for more than 2 hours on my mac.
I earlier used Searchable plugin which used to start the app in less than 2 mins.
Is there a way to integrate marvel or any other admin script to see what is going on ?
I am using grails 2.4.2

ERROR unmarshall.DomainClassUnmarshaller when searching parent-child

I'm getting a weird error when searching for domains mapped as parent-child.

Here's how to recreate the error:

Domains

Class Parent{

    String parentName

    static hasMany = [child: Child]

    static searchable = {
        child reference:true
  }

}

Class Child{
    String childName

    static belongsTo = [parent: parent]

    static searchable = {
        parent parent:true, reference:true
   }
}

This mapping is properly created, however, when searching using the following method:

    def searchParentOrderByChildCount(){
        def list = Parent.search([sort: "_score", order: "desc"],{
            bool{
                should{
                    has_child(
                        type:"child",
                        score_mode: "sum",
                        query: QueryBuilders.matchAllQuery()
                    )
                }
            }
    })
}

My console goes wild and logs a strange error for each matching object:

| Error 2014-10-20 15:40:47,706 [http-bio-8080-exec-4] ERROR unmarshall.DomainClassUnmarshaller  - Error unmarshalling Class Parent with id 3

Then the following lines (a few hundred of them):

selection_009

This seems to be coming from the buildResults method of org.grails.plugins.elasticsearch.conversion.unmashall.DomainClassUnmarshaller, lines 82-85, but I don't understand why the error is thrown.

Any ideas?

QueryParsingException: Failed to find geo_point field

I have two domain classes that mirror the GeoPoint examples exactly. Yet, in my tests I keep getting the error
QueryParsingException[[package] failed to find geo_point field [location]]; }
My Building class is

class Building {
  GeoPoint location

  static searchable = {
    location geoPoint: true, component: true
  }
}

I do create the GeoPoint in a beforeValidate block, but it appears to be indexed with the correct data:

Indexing class package.Building (index: package , type: building) of id 57 and source {"category":null,"location":{"id":2,"class":"package.GeoPoint","lat":40.15,"lon":5.699999999999999}

The location is not being mapped as a geo_point.
I can get the mapping for my class as

[properties:[location:[properties:[class:[type:string], id:[type:long], lat:[type:double], lon:[type:double]]]]] 

While the mapping in the test class of this plugin is:

[properties:[location:[type:geo_point], name:[type:string, term_vector:with_positions_offsets, include_in_all:true]]]

Cannot successfully build the Plugin from latest version

Hi,
We are experiencing an issue with the latest version of the plugin (0.0.2.4). I've identified where the problem seems to be happening by debugging in IntelliJ and would like to try out some changes myself before submitting a bug against the plugin.

However we are having some issues building the plugin from sources or running the tests. The application.properties has a grails version of 2.1.4, but if we build with this version I get a class not found exception for GrailsProjectPackager.... because the package has changed for this class in Grails 2.3.7. However if we try building with Grails 2.3.7 we get other issues because the BuildConfig has hibernate and tomcat plugins specified at V 2.1.4

COuld you let us know exactly what Grails version you are currently using to build and test the plugin. This would fast forward us to further investigating the other problem and hopefully issuing a pull request for a fix.

Regards

Fergal Dearle

Mapping to a schema not matching domain class schema.

I have an application, where I want most fields to be directly on a single domain class when it comes to mapping into elasticsearch, but I have the field split between multiple domains in my application.

For example, I have a Building class with an Address field, and the Address type has geolocation information. I want to map the Building class to elasticsearch so that it has the geolocation information as a field to facilitate more readable queries and more performant searching.

Right now I see 2 ways of doing this:

  1. Add a GeoPoint field to the Building class with the location information and don't index the address. I dislike this method because it pollutes my domain class and my database with information my application doesn't need. If we could map transient properties the database could be saved of pollution.
  2. Allow some way of the user to define how the mapping is done. I think this would best be accomplished by allowing a user to override a method like "asIndexedJson", similar to how elasticsearch-rails does it. We would also have to allow a user a way to define the mapping in addition to the indexed json.

I'm capable of implementing any of this, I just want opinions on how best to go about it.

Thanks!

Index domain class with composite id not being indexed

I do have a class with a composite Id that does not get indexed with elasticsearch. This class is referenced in One-To-Many, and gets indexed only if I update the relationship (Add, Remove Element). However, after restarting the server and when elasticsearch does the auto index, it disappears from the index.

Getting weird gorm synchonize issue with latest 0.2.3 and Grais 2.3.5

Started to noticed that I am getting a lot of

org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect):

or

ERROR events.PatchedDefaultFlushEventListener - Could not synchronize database state with session Message: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect):

errors and traced it to the installation of the new elasticsearch-gorm 0.0.2.3 plugin.
Everything goes back to normal once I removed the plugin.

The general behavior is that saving/updating of data goes well initially but begin to throw StaleObjectStateException after a while.
Child objects that were deleted off will appear again even thought the database doesn't contain the records anymore.
And then any save/update/delete operations will be met with violent PatchedDefaultFlushEventListener exceptions.

It looks like some kind of caching of gorm objects after indexing that is interfering with gorm.

:-(

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.