Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you search collections in a domain class? #221

Open
kevintanhongann opened this issue Mar 25, 2018 · 0 comments
Open

How do you search collections in a domain class? #221

kevintanhongann opened this issue Mar 25, 2018 · 0 comments

Comments

@kevintanhongann
Copy link

kevintanhongann commented Mar 25, 2018

def filter = {
            nested {
                path('permissions')
                query {
                    bool {
                        must {
                            term("permissions.authority": 'Admin')
                        }
                    }
                }
            }
        }
        def results = elasticSearchService.search(keyword, filter,[indices: Company, types: Company, from: 0, size: 10])

And I got this stacktrace

java.lang.reflect.InvocationTargetException: null
        at org.grails.core.DefaultGrailsControllerClass$ReflectionInvoker.invoke(DefaultGrailsControllerClass.java:211)
        at org.grails.core.DefaultGrailsControllerClass.invoke(DefaultGrailsControllerClass.java:188)
        at org.grails.web.mapping.mvc.UrlMappingsInfoHandlerAdapter.handle(UrlMappingsInfoHandlerAdapter.groovy:90)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
        at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)
        at org.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:77)
        at org.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:67)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Array elements must be defined with the "element" method call eg: element(value)
        at grails.plugins.elasticsearch.util.GXContentBuilder.invokeMethod(GXContentBuilder.groovy:120)
        at haulage.project.SearchService$_searchCompanyByHaulier_closure6$_closure13.doCall(SearchService.groovy:102)
        at grails.plugins.elasticsearch.util.GXContentBuilder.handleClosureNode(GXContentBuilder.groovy:166)
        at grails.plugins.elasticsearch.util.GXContentBuilder.invokeMethod(GXContentBuilder.groovy:117)
        at haulage.project.SearchService$_searchCompanyByHaulier_closure6.doCall(SearchService.groovy:101)
        at grails.plugins.elasticsearch.util.GXContentBuilder.buildRoot(GXContentBuilder.groovy:72)
        at grails.plugins.elasticsearch.util.GXContentBuilder.build(GXContentBuilder.groovy:45)
        at grails.plugins.elasticsearch.util.GXContentBuilder.buildAsBytes(GXContentBuilder.groovy:61)
        at grails.plugins.elasticsearch.util.GXContentBuilder.buildAsBytes(GXContentBuilder.groovy:56)
        at grails.plugins.elasticsearch.ElasticSearchService.setFilterInSource(ElasticSearchService.groovy:433)
        at grails.plugins.elasticsearch.ElasticSearchService.buildSearchRequest(ElasticSearchService.groovy:371)
        at grails.plugins.elasticsearch.ElasticSearchService.search(ElasticSearchService.groovy:116)
        at haulage.project.SearchService.searchCompanyByHaulier(SearchService.groovy:112)
        at haulage.project.SearchController.haulierCompany(SearchController.groovy:247)
        ... 14 common frames omitted

How do I define the element method call? Any pointers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant