Эластичный поиск + грааль метания NPE

Это продолжение этого вопроса плагин эластичного поиска Grails с отображением текста

Я выполнил шаги, указанные в ответе, и теперь выбрасывается следующий NPE. Кроме того, если я открываю индекс lucene с помощью Luke, я не вижу в нем никаких документов.

Хотя при перезапуске сервера приложений я получаю следующие отладочные сообщения

2013-06-03 16:20:49,364 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator  - Retrieved index settings
2013-06-03 16:20:49,365 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator  - Installing mappings...
2013-06-03 16:20:49,370 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator  - Index com.ecw.wellness does not exists, initiating creation...
2013-06-03 16:20:49,370 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator  - Waiting at least yellow status on com.ecw.wellness ...
2013-06-03 16:21:19,869 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator  - {com_ecw_wellness_answer={properties={answer={type=string, include_in_all=true, term_vector=with_positions_offsets}, votes={type=object}, dateCreated={type=date, include_in_all=true}, lastUpdated={type=date, include_in_all=true}, question={type=object}}}}
2013-06-03 16:21:19,869 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator  - [com_ecw_wellness_answer] => {com_ecw_wellness_answer={properties={answer={type=string, include_in_all=true, term_vector=with_positions_offsets}, votes={type=object}, dateCreated={type=date, include_in_all=true}, lastUpdated={type=date, include_in_all=true}, question={type=object}}}}
2013-06-03 16:21:19,925 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator  - [com_ecw_wellness_comment] => {com_ecw_wellness_comment={properties={post={type=object}, vote={type=integer, include_in_all=true}, dateCreated={type=date, include_in_all=true}, lastUpdated={type=date, include_in_all=true}, comment={type=string, include_in_all=true, term_vector=with_positions_offsets}}}}
2013-06-03 16:21:19,977 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator  - [com_ecw_wellness_post] => {com_ecw_wellness_post={properties={tags={type=object}, body={type=string, include_in_all=true, term_vector=with_positions_offsets}, title={type=string, include_in_all=true, term_vector=with_positions_offsets}, dateCreated={type=date, include_in_all=true}, lastUpdated={type=date, include_in_all=true}, comments={properties={post={type=object}, vote={type=integer, include_in_all=true}, dateCreated={type=date, include_in_all=true}, lastUpdated={type=date, include_in_all=true}, comment={type=string, include_in_all=true, term_vector=with_positions_offsets}, id={type=long, index=not_analyzed, include_in_all=false}, class={type=string, index=no, include_in_all=false}, ref={type=string, index=no, include_in_all=false}}, type=object}}}}
2013-06-03 16:21:20,005 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator  - [com_ecw_wellness_question] => {com_ecw_wellness_question={properties={tags={type=object}, title={type=string, include_in_all=true, term_vector=with_positions_offsets}, answers={type=object}, dateCreated={type=date, include_in_all=true}, lastUpdated={type=date, include_in_all=true}, question={type=string, include_in_all=true, term_vector=with_positions_offsets}}}}
2013-06-03 16:21:20,010 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator  - Cluster status: GREEN

Ниже приведена трассировка стека NPE. Классы предметной области указаны в исходном вопросе.

| Error 2013-06-03 16:17:00,891 [http-bio-8080-exec-8] ERROR errors.GrailsExceptionResolver  - NullPointerException occurred when processing request: [GET] /wellness/search - parameters:
q: smoking
Stacktrace follows:
Message: null
    Line | Method
->>  181 | unmarshallProperty in org.grails.plugins.elasticsearch.conversion.unmarshall.DomainClassUnmarshaller
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|     73 | buildResults       in     ''
|    435 | doCall . . . . . . in org.grails.plugins.elasticsearch.ElasticSearchService$_doSearch_closure7
|     14 | withElasticSearch  in org.grails.plugins.elasticsearch.ElasticSearchHelper
|    426 | doSearch . . . . . in org.grails.plugins.elasticsearch.ElasticSearchService
|     86 | search             in     ''
|      6 | index . . . . . .  in com.ecw.wellness.SearchController
|    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

Если я запускаю проект в транспортном режиме со следующей информацией, я получаю «Нет доступной ошибки узла»

elasticSearch.client.mode = 'transport'
        elasticSearch.client.hosts = [
            [host:'localhost', port:9300]
     ]
    }

Если бы я добавил следующее в сообщение

 static searchable = {
    except = ["user"]
comments reference:true

}

а это в комментарии

    static searchable = {
    except = ["user"]
    post reference:true
}

Затем я получаю следующее исключение SO. И если я делаю это только в почтовом классе, я получаю ошибку Property Comment.post is not mapped as [component], but broken search hit found. во время выполнения

    ERROR errors.GrailsExceptionResolver  - StackOverflowError occurred when processing request: [GET] /wellness/search - parameters:
q: smoking
Stacktrace follows:
Message: Executing action [index] of controller [com.ecw.wellness.SearchController]  caused exception: Runtime error executing action
    Line | Method
->>  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
Caused by ControllerExecutionException: Runtime error executing action
->>  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
Caused by InvocationTargetException: null
->>  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
Caused by StackOverflowError: null
->>  354 | findClass in java.net.URLClassLoader
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    171 | oldFindClass in org.codehaus.groovy.tools.RootLoader
|    143 | loadClass in     ''
|    356 | loadClass in java.lang.ClassLoader
|    263 | unmarshallDomain in org.grails.plugins.elasticsearch.conversion.unmarshall.DomainClassUnmarshaller
|    256 | unmarshallReference in     ''
|    178 | unmarshallProperty in     ''
|    204 | unmarshallProperty in     ''
|    268 | unmarshallDomain in     ''
|    256 | unmarshallReference in     ''
|    178 | unmarshallProperty in     ''
|    268 | unmarshallDomain in     ''
|    256 | unmarshallReference in     ''
|    178 | unmarshallProperty in     ''
|    204 | unmarshallProperty in     ''
|    268 | unmarshallDomain in     ''
|    256 | unmarshallReference in     ''
|    178 | unmarshallProperty in     ''
|    268 | unmarshallDomain in     ''
|    256 | unmarshallReference in     ''
|    178 | unmarshallProperty in     ''
|    204 | unmarshallProperty in     ''

person Sap    schedule 03.06.2013    source источник


Ответы (1)


Добавьте elasticSearch.unmarshallComponents = true в свой Config.groovy. Предполагается, что в файле grails-app/conf/DefaultElasticSearch.groovy плагина должно быть указано значение по умолчанию, но почему-то оно не загружается должным образом.

Также см. issue#62 в репозитории Github

В транспортном режиме требуется, чтобы автономный экземпляр ES работал вне приложения Grails.


Изменить: об этой проблеме:

Свойство Comment.post не отображается как [компонент], но обнаружен неверный результат поиска.

Вам нужно отобразить в доступном для поиска замыкании ваши ассоциации либо как доступные для поиска component, либо reference. В документации плагина указано, что ссылки с возможностью поиска используются по умолчанию, но это почему-то уже не соответствует действительности, и документ немного устарел.

Ссылка по умолчанию на доступную для поиска ссылку была удалена в предыдущей версии по причине, которую я сейчас не могу вспомнить, поэтому, возможно, поведение по умолчанию будет восстановлено в будущей версии...

Пример ниже:

class Comment {
    Post post
    static belongsTo = [post:Post]

    static searchable = {
            post component:true
    }
}

Документация, объясняющая разница между двумя моделями поведения

person mstein    schedule 03.06.2013
comment
››Транспортный режим требует, чтобы автономный экземпляр ES работал вне приложения grails. У меня работает. Спасибо за ответ, надеюсь, что это заставит меня работать - person Sap; 03.06.2013
comment
Все та же проблема, я добавил флаг в CONfig.groovy, очистил каталог данных, перезапустил приложение и получил -›› 181 | unmarshallProperty в DomainClassUnmarshaller.java - person Sap; 03.06.2013
comment
мой плохой, я опечатался elasticSearch.unmarshallComponents на unmarshallProperty... Я обновил сообщение. Добавляемый ключ конфигурации: elasticSearch.unmarshallComponents. - person mstein; 03.06.2013
comment
Теперь я получаю эту ошибку Property Comment.post is not mapped as [component], but broken search hit found. - person Sap; 03.06.2013
comment
Вам необходимо установить свойство reference:true или component:true для ваших ассоциаций. В документе указано, что поисковая ссылка используется по умолчанию, но это уже не так. IE: static searchable = { post component:true } - person mstein; 04.06.2013
comment
Я пробовал это долгое время назад, но это ничего не дает, если я делаю component:true как в Comment, так и в Post друг для друга, тогда я получаю ошибку переполнения стека. вы можете найти трассировку стека в моем последнем редактировании - person Sap; 04.06.2013