Using Script field in Search Query


(Rahul Sharma) #1

Hi,

Stuck with a simple issue, it would be really great if any of you can help
me out.

Trying to use a scriptField in a search query. But as I execute the query,
it runs forever does not come out of execution. Am I doing something wrong.
Here is the code:

SearchRequestBuilder builder = client.prepareSearch(indexName);
SearchResponse searchResponse =
builder.setQuery(matchAllQuery()).addScriptField("Amount1",
"doc['amount'].value").execute().actionGet();

Does not throw any exception, at the same time does not come out of
execution. Just hangs.

I am using elasticsearch-0.18.5

Thanks
Rahul


(jagdeep) #2

Which Port you bare using? 9300 or 9200?
Please give more details about mapping and configuration.

On May 1, 12:16 pm, Rahul Sharma rahul.sharma.co...@gmail.com wrote:

Hi,

Stuck with a simple issue, it would be really great if any of you can help
me out.

Trying to use a scriptField in a search query. But as I execute the query,
it runs forever does not come out of execution. Am I doing something wrong.
Here is the code:

SearchRequestBuilder builder = client.prepareSearch(indexName);
SearchResponse searchResponse =
builder.setQuery(matchAllQuery()).addScriptField("Amount1",
"doc['amount'].value").execute().actionGet();

Does not throw any exception, at the same time does not come out of
execution. Just hangs.

I am using elasticsearch-0.18.5

Thanks
Rahul


(Rahul Sharma) #3

Am using default configuration which uses 9300.
I am storing "amount" as a field which is a double field.

If I don't use scriptField and just use the below query then I get back all
the documents as expected.
builder.setQuery(matchAllQuery()).execute().actionGet();

But when I add scriptField its goes real searching. I tried with String
field (which is not analyzed) as well. Same result.

Thanks
Rahul

On Tue, May 1, 2012 at 1:02 PM, jagdeep singh reach.jagdeep@gmail.comwrote:

Which Port you bare using? 9300 or 9200?
Please give more details about mapping and configuration.

On May 1, 12:16 pm, Rahul Sharma rahul.sharma.co...@gmail.com wrote:

Hi,

Stuck with a simple issue, it would be really great if any of you can
help
me out.

Trying to use a scriptField in a search query. But as I execute the
query,
it runs forever does not come out of execution. Am I doing something
wrong.
Here is the code:

SearchRequestBuilder builder = client.prepareSearch(indexName);
SearchResponse searchResponse =
builder.setQuery(matchAllQuery()).addScriptField("Amount1",
"doc['amount'].value").execute().actionGet();

Does not throw any exception, at the same time does not come out of
execution. Just hangs.

I am using elasticsearch-0.18.5

Thanks
Rahul


(Rahul Sharma) #4

Doing some further research, I could see that the search response is fine
till

NettyTransportChannel.java --- sendResponse(Streamable message,
TransportResponseOptions options)
I assume it should return back the control after
channel.write(buffer), but it does not seem like happening.

Whereas if I do regular search without addScrieptField everything works fine
.
Note
: Though Scripts are working fine when its used with Facets.

Would appreciate your suggestion / pointers.

Am I doing something wrong or its a potential bug?

Thanks
Rahul

On Tue, May 1, 2012 at 1:13 PM, Rahul Sharma
rahul.sharma.coder@gmail.comwrote:

Am using default configuration which uses 9300.
I am storing "amount" as a field which is a double field.

If I don't use scriptField and just use the below query then I get back
all the documents as expected.
builder.setQuery(matchAllQuery()).execute().actionGet();

But when I add scriptField its goes real searching. I tried with String
field (which is not analyzed) as well. Same result.

Thanks
Rahul

On Tue, May 1, 2012 at 1:02 PM, jagdeep singh reach.jagdeep@gmail.comwrote:

Which Port you bare using? 9300 or 9200?
Please give more details about mapping and configuration.

On May 1, 12:16 pm, Rahul Sharma rahul.sharma.co...@gmail.com wrote:

Hi,

Stuck with a simple issue, it would be really great if any of you can
help
me out.

Trying to use a scriptField in a search query. But as I execute the
query,
it runs forever does not come out of execution. Am I doing something
wrong.
Here is the code:

SearchRequestBuilder builder = client.prepareSearch(indexName);
SearchResponse searchResponse =
builder.setQuery(matchAllQuery()).addScriptField("Amount1",
"doc['amount'].value").execute().actionGet();

Does not throw any exception, at the same time does not come out of
execution. Just hangs.

I am using elasticsearch-0.18.5

Thanks
Rahul


(Rahul Sharma) #5

I could solve the issue by upgrading to 0.19.3
But unfortunately I could not find a bug logged around this which got
solved post 0.18.5

BTW, this can be replicated for addField as well.

On Tue, May 1, 2012 at 11:40 PM, Rahul Sharma
rahul.sharma.coder@gmail.comwrote:

Doing some further research, I could see that the search response is fine
till

NettyTransportChannel.java --- sendResponse(Streamable message,
TransportResponseOptions options)
I assume it should return back the control after
channel.write(buffer), but it does not seem like happening.

Whereas if I do regular search without addScrieptField everything works
fine*.
Note*: Though Scripts are working fine when its used with Facets.

Would appreciate your suggestion / pointers.

Am I doing something wrong or its a potential bug?

Thanks
Rahul

On Tue, May 1, 2012 at 1:13 PM, Rahul Sharma <rahul.sharma.coder@gmail.com

wrote:

Am using default configuration which uses 9300.
I am storing "amount" as a field which is a double field.

If I don't use scriptField and just use the below query then I get back
all the documents as expected.
builder.setQuery(matchAllQuery()).execute().actionGet();

But when I add scriptField its goes real searching. I tried with String
field (which is not analyzed) as well. Same result.

Thanks
Rahul

On Tue, May 1, 2012 at 1:02 PM, jagdeep singh reach.jagdeep@gmail.comwrote:

Which Port you bare using? 9300 or 9200?
Please give more details about mapping and configuration.

On May 1, 12:16 pm, Rahul Sharma rahul.sharma.co...@gmail.com wrote:

Hi,

Stuck with a simple issue, it would be really great if any of you can
help
me out.

Trying to use a scriptField in a search query. But as I execute the
query,
it runs forever does not come out of execution. Am I doing something
wrong.
Here is the code:

SearchRequestBuilder builder = client.prepareSearch(indexName);
SearchResponse searchResponse =
builder.setQuery(matchAllQuery()).addScriptField("Amount1",
"doc['amount'].value").execute().actionGet();

Does not throw any exception, at the same time does not come out of
execution. Just hangs.

I am using elasticsearch-0.18.5

Thanks
Rahul


(Shay Banon) #6

Can you first try and see if it happens with a later version? Its strange
that you get it... . If it does, can you write a simple Java program that
recreates the problem?

On Tue, May 1, 2012 at 10:52 PM, Rahul Sharma
rahul.sharma.coder@gmail.comwrote:

I could solve the issue by upgrading to 0.19.3
But unfortunately I could not find a bug logged around this which got
solved post 0.18.5

BTW, this can be replicated for addField as well.

On Tue, May 1, 2012 at 11:40 PM, Rahul Sharma <
rahul.sharma.coder@gmail.com> wrote:

Doing some further research, I could see that the search response is fine
till

NettyTransportChannel.java --- sendResponse(Streamable message,
TransportResponseOptions options)
I assume it should return back the control after
channel.write(buffer), but it does not seem like happening.

Whereas if I do regular search without addScrieptField everything works
fine*.
Note*: Though Scripts are working fine when its used with Facets.

Would appreciate your suggestion / pointers.

Am I doing something wrong or its a potential bug?

Thanks
Rahul

On Tue, May 1, 2012 at 1:13 PM, Rahul Sharma <
rahul.sharma.coder@gmail.com> wrote:

Am using default configuration which uses 9300.
I am storing "amount" as a field which is a double field.

If I don't use scriptField and just use the below query then I get back
all the documents as expected.
builder.setQuery(matchAllQuery()).execute().actionGet();

But when I add scriptField its goes real searching. I tried with String
field (which is not analyzed) as well. Same result.

Thanks
Rahul

On Tue, May 1, 2012 at 1:02 PM, jagdeep singh reach.jagdeep@gmail.comwrote:

Which Port you bare using? 9300 or 9200?
Please give more details about mapping and configuration.

On May 1, 12:16 pm, Rahul Sharma rahul.sharma.co...@gmail.com wrote:

Hi,

Stuck with a simple issue, it would be really great if any of you can
help
me out.

Trying to use a scriptField in a search query. But as I execute the
query,
it runs forever does not come out of execution. Am I doing something
wrong.
Here is the code:

SearchRequestBuilder builder = client.prepareSearch(indexName);
SearchResponse searchResponse =
builder.setQuery(matchAllQuery()).addScriptField("Amount1",
"doc['amount'].value").execute().actionGet();

Does not throw any exception, at the same time does not come out of
execution. Just hangs.

I am using elasticsearch-0.18.5

Thanks
Rahul


(Rahul Sharma) #7

I did not try in later version of 0.18 series.
As I was upgrading so I did to the most recent which is 0.19.3

Will try it out sometime this weekend and let you know.

Thanks
Rahul

On Wed, May 2, 2012 at 10:01 PM, Shay Banon kimchy@gmail.com wrote:

Can you first try and see if it happens with a later version? Its strange
that you get it... . If it does, can you write a simple Java program that
recreates the problem?

On Tue, May 1, 2012 at 10:52 PM, Rahul Sharma <
rahul.sharma.coder@gmail.com> wrote:

I could solve the issue by upgrading to 0.19.3
But unfortunately I could not find a bug logged around this which got
solved post 0.18.5

BTW, this can be replicated for addField as well.

On Tue, May 1, 2012 at 11:40 PM, Rahul Sharma <
rahul.sharma.coder@gmail.com> wrote:

Doing some further research, I could see that the search response is
fine till

NettyTransportChannel.java --- sendResponse(Streamable message,
TransportResponseOptions options)
I assume it should return back the control after
channel.write(buffer), but it does not seem like happening.

Whereas if I do regular search without addScrieptField everything works
fine*.
Note*: Though Scripts are working fine when its used with Facets.

Would appreciate your suggestion / pointers.

Am I doing something wrong or its a potential bug?

Thanks
Rahul

On Tue, May 1, 2012 at 1:13 PM, Rahul Sharma <
rahul.sharma.coder@gmail.com> wrote:

Am using default configuration which uses 9300.
I am storing "amount" as a field which is a double field.

If I don't use scriptField and just use the below query then I get back
all the documents as expected.
builder.setQuery(matchAllQuery()).execute().actionGet();

But when I add scriptField its goes real searching. I tried with String
field (which is not analyzed) as well. Same result.

Thanks
Rahul

On Tue, May 1, 2012 at 1:02 PM, jagdeep singh reach.jagdeep@gmail.comwrote:

Which Port you bare using? 9300 or 9200?
Please give more details about mapping and configuration.

On May 1, 12:16 pm, Rahul Sharma rahul.sharma.co...@gmail.com wrote:

Hi,

Stuck with a simple issue, it would be really great if any of you
can help
me out.

Trying to use a scriptField in a search query. But as I execute the
query,
it runs forever does not come out of execution. Am I doing something
wrong.
Here is the code:

SearchRequestBuilder builder = client.prepareSearch(indexName);
SearchResponse searchResponse =
builder.setQuery(matchAllQuery()).addScriptField("Amount1",
"doc['amount'].value").execute().actionGet();

Does not throw any exception, at the same time does not come out of
execution. Just hangs.

I am using elasticsearch-0.18.5

Thanks
Rahul


(system) #8