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

Not working with Java API using transport client. Hrows NullPointerException #12

Open
kajal23 opened this issue Jul 31, 2013 · 2 comments

Comments

@kajal23
Copy link

kajal23 commented Jul 31, 2013

I am trying to use this plugin But I am having trouble using it.
It works fine with rest API /elastic search head. But When I try to execute it using Es Java API it throws null pointer exception. I am using elastic search version 0.90.0 and this plugin version 1.1.0.

Here is the exception I get

        Caused by: java.lang.NullPointerException   at org.elasticsearch.search.facet.InternalFacets.readFrom(InternalFacets.java:144)
at org.elasticsearch.search.facet.InternalFacets.readFacets(InternalFacets.java:130)
at org.elasticsearch.search.internal.InternalSearchResponse.readFrom(InternalSearchResponse.java:99)
at org.elasticsearch.search.internal.InternalSearchResponse.readInternalSearchResponse(InternalSearchResponse.java:91)
at org.elasticsearch.action.search.SearchResponse.readFrom(SearchResponse.java:219)
at org.elasticsearch.transport.netty.MessageChannelHandler.handleResponse(MessageChannelHandler.java:148)

Here is the code,
I am using elasicsearch transport client.

        SearchRequestBuilder srb = getClient().prepareSearch()
                .setSearchType(SearchType.COUNT)
                .setIndices(esConfig.getIndexName());

    srb.setExtraSource(XContentFactory.jsonBuilder().startObject()
                .startObject("facets")
                .startObject("facet1")
                .startObject("script")
                .field("init_script", "charfreq_init")
                .field("map_script", "charfreq_map")
                .field("reduce_script", "charfreq_reduce")
                .startObject("params")
                .startArray("facet")
                .endArray()
                .field("field", "DATA_ID")
                .endObject()
                .endObject()
                .endObject()
                .endObject()
                .endObject());
    response = srb.execute().actionGet();
@kajal23
Copy link
Author

kajal23 commented Aug 1, 2013

I was debugging through it and realize it is not registering the stream for internalScriptFacet. Since its not registering it doesn't know how to read and write from the stream.
I don't know the solution though. I installed the plugin as upu suggested here I was debugging through it and realize it not registering the stream for internalScriptFacet. SInce its not registering it doesnt know how to read and write from the stream.
I don't know the solution though. I installed the plugin as you suggested here https://github.com/imotov/elasticsearch-facet-script

@imotov
Copy link
Owner

imotov commented Aug 6, 2013

Yes, there are a couple of issues there. The NPE that you are getting is indeed caused by the facet not registering stream in case of the transport client. I am still trying to think of a better way to fix it, but as a work around you can try registering it manually before using the facet like this:

InternalScriptFacet.registerStreams(null, null);

The second problem was caused by the final facet serialization. It's fixed by 147d602. Please, give it a try and let me know if it works for you.

@kajal23 kajal23 closed this as completed Jan 20, 2014
@kajal23 kajal23 reopened this Jan 20, 2014
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

2 participants