0

这是对这个问题的跟进 Grails elasticsearch plugin with "text" mapping

我按照答案中给出的步骤进行操作,现在抛出了 NPE。另外,如果我使用 Luke 打开 lucene 索引,那么我看不到任何文档。

虽然在重新启动应用服务器时给了我以下调试消息

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     ''
4

1 回答 1

0

添加elasticSearch.unmarshallComponents = true您的Config.groovy. 应该在grails-app/conf/DefaultElasticSearch.groovy插件的文件中提供一个默认值,但不知何故它没有正确加载。

另请参阅 Github 存储库上的 issue#62

传输模式需要一个独立的 ES 实例才能在 grails 应用程序之外运行。


编辑: 关于这个问题:

属性 Comment.post 未映射为 [组件],但发现损坏的搜索命中。

您需要在可搜索闭包中将您的关联映射为可搜索componentreference. 插件文档指出默认情况下使用可搜索的引用,但不知何故不再正确,文档有点过时了。

由于我目前不记得的原因,在以前的版本中删除了可搜索引用的默认设置,因此可能会在将来的版本中恢复默认行为......

下面的例子:

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

    static searchable = {
            post component:true
    }
}

解释这两种行为之间差异的文档

于 2013-06-03T13:47:19.187 回答