CURL returns immediately whereas RestClient timesout

Hi,

I'm using elasticsearch version 6.4.

An index pri.store.size is 25GB and it contains 47 Million documents.
My query includes a termsquery and cardinality.

When i execute the query using CURL i got the response in 3-4 seconds.

But when the same query is executed by RestClient java api, i got the exception java.io.IOException: listener timeout after waiting for [30000] ms.

Then i increased my setMaxRetryTimeoutMillis to 60000. Still timeout happened. Then further to 90 seconds, 2 minute, 10 min, 20 min. I failed every time.

What i'm missing?

Simple queries are executed successfully via RestClient. But a query with termsquery and cardinality timesout everytime (only RestClient fails but CURL returns response)

Help me to achieve via RestClient.

I'd say that you are not exactly running the same thing.

Could you share both things:

  • The curl query you ran
  • The Java code you used

This is how i queried.
Using CURL:

curl -XGET "localhost:9200/my_index_name/_search?pretty" -H 'Content-Type: application/json' -d'{
	"query":{
		"bool":{
			"must":[
				{"terms":{"Operation":["Operation", "SIGN_IN", "SIGN_OUT", "VALIDATE"]}}
			]
		}
	},
	"aggs":{
		"TokenCards":{
			"cardinality":{
				"field":"Token"
			}
		}
	}
}'

USING JAVA:

		BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
		TermsQueryBuilder termsQueryBuilder = new TermsQueryBuilder("Operation", "SIGN_IN", "SIGN_OUT", "VALIDATE");
		SearchRequest request = new SearchRequest("my_index_name");
		SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
		sourceBuilder.query(boolQueryBuilder.must(termsQueryBuilder));
		sourceBuilder.aggregation(AggregationBuilders.cardinality("TokenCards").field("Token"));
		request.source(sourceBuilder);
		SearchResponse searchResponse = client.search(request, RequestOptions.DEFAULT);

Please format your code according to the rules of this forum. I edited your post to make it readable but next time please do it.

Can you share the full content of:

searchResponse.toString();

And the full content of your curl call:

curl -XGET "localhost:9200/my_index_name/_search?pretty" -H 'Content-Type: application/json' -d'{
...

Full response of my curl call:

    {
      "took" : 10890,
      "timed_out" : false,
      "_shards" : {
        "total" : 21,
        "successful" : 21,
        "skipped" : 0,
        "failed" : 0
      },
      "hits" : {
        "total" : 1250832,
        "max_score" : 0.0,
        "hits" : [ ]
      },
      "aggregations" : {
        "TokenCards" : {
          "value" : 1262042
        }
      }
    }

searchResponse is null because of listener timeout exception.

Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

This is the icon to use if you are not using markdown format:

There's a live preview panel for exactly this reasons.

Here I think you edited the response right?
hits can not be empty.

I just executed the same query by giving

"size":100

I don't understand.

If you need help you must:

  • Provide the exact queries/code you are running with no modification
  • Provide the exact results you are getting without any modification (or at least clearly state what has been modified)

If this forum does not allow you uploading a big piece of code, please upload it to gist.github.com and share the link here.

Oops. I'm so sorry.

Its a typo.

I mean't be say i just executed the query by giving

"size": 0

Reason for typo is that when i enter : followed by 0 it displays some suggestion and replaces my content and i didn't notice that. Sorry for that.

Cardinality value is my need. So i give size:0.

Please help me.

If you need help answer the questions I asked.

You asked two things.
1.searchResponse.toString();
It is null
2.full content of your curl call:
I shared you that.

what more do you want ? :slight_smile:

Let me copy and paste the relevant part:

If you need help you must:

  • Provide the exact queries/code you are running with no modification
  • Provide the exact results you are getting without any modification (or at least clearly state what has been modified)

By the way, are you able to execute a simple MatchAllQuery using your Java code?

Yes. MatchAllQuery woks fine.

Even TermsQuery works normally. But when it comes to cardinality, timesout happening .

@dadoonet Can you please help me? _/\_

if you do not provide the information people are requesting when trying to help you, it is possible that people lose patience and possibly give up. This forum is manned by volunteers, so no one has any obligation to respond to a thread until it has been resolved. I would therefore recommend trying to help the people helping you as much as possible.

2 Likes

Cool. I understand. But some details i cannot share, that's the reason.

Then it is virtually impossible for us to help...

Okay fine. Let me check if any other have the same problem.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.