Elastic Search No query registered for [geo_bounding_box] - elasticsearch

I am trying to fetch records from Elastic search and i get this error as below
ElasticsearchStatusException[Elasticsearch exception [type=exception, reason=SearchPhaseExecutionException[Failed to execute phase [query_fetch], all shards failed;
shardFailures {[-kDbP0fmTUa5B8v1gpgoZQ][dataintelindex_ra][0]: SearchParseException[[dataintelindex_ra]
[0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"geo_bounding_box":{"loc":
{"top_left":[-74.1,40.73],"bottom_right":
[-73.99,40.717]},"validation_method":"STRICT","type":"MEMORY","ignore_unmapped":false,"boost":1.0}}}]]];
nested: QueryParsingException[[dataintelindex_ra] No query registered for [geo_bounding_box]]; }]]]
My Java Code is as below
SearchRequest searchRequest = new SearchRequest("dataintelindex_ra").types("station_info");
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(QueryBuilders.geoBoundingBoxQuery("loc").setCorners(40.73,-74.1,40.717,-73.99));
searchRequest.source(searchSourceBuilder);
SearchResponse response = elasticSearchClient.search(searchRequest, RequestOptions.DEFAULT);
for (SearchHit searchHit : response.getHits().getHits()) {
System.out.println("~~~~~~~~SearchHit[] searchHits~~~~~~~~~~~~~~ "+searchHit.getSourceAsString());
}
Please let me know if i missed something while trying to index , i am new to Elastic search.
Also incase if i want to include one more criteria to my query like below
searchSourceBuilder.query(QueryBuilders.termsQuery("zoneType", ["test","oms"]));
Below is the result for the above query and it works fine
~~~~~~~~SearchHit[] searchHits~~~~~~~~~~~~~~ {"tag_datatype":"sensor","loc":[{"lat":"0","lon":"0"}],"level":1,"kml_path":"","created":"Mon Aug 10 16:02:51 IST 2020","latitude":"0","station_id":"5f312253b4c93c1d20bbbb39","longtitude":"0","tag_owner":"","description":"","zoneType":"oms","tag_network_name":"chak_network","display_name":"506020200236117-O1","supply_zone":"506020200236117-O1","outflow":null,"tag_sector":"dmameter","name":"506020200236117-O1","tag_category":"sensorstation","inflow":null,"_id":"5f312253b4c93c1d20bbbb39","tag_location":"NA","lastmod":"Mon Aug 10 16:02:51 IST 2020","status":"ACTIVE"}
~~~~~~~~SearchHit[] searchHits~~~~~~~~~~~~~~ {"tag_datatype":"sensor","loc":[{"lat":"0","lon":"0"}],"level":1,"kml_path":"","created":"Tue Aug 11 11:36:51 IST 2020","latitude":"0","station_id":"5f32357b3ccb8f51e003587e","longtitude":"0","tag_owner":"","description":"","zoneType":"village","display_name":"testvillage1","supply_zone":"testvillage1","outflow":null,"tag_sector":"dmameter","name":"testvillage1","tag_category":"sensorstation","inflow":null,"_id":"5f32357b3ccb8f51e003587e","tag_location":"NA","lastmod":"Tue Aug 11 11:36:51 IST 2020","status":"ACTIVE"}
how do i combine with above geoboundingbox query ? do i need to add it as a filter?
Update : Dependencies
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>6.4.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>6.4.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
<version>6.4.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>6.4.0</version>
</dependency>
{
"status" : 200,
"name" : "test1",
"version" : {
"number" : "1.2.2",
"build_hash" : "243243432feaga",
"build_timestamp" : "2014-07-09T12:02:32Z",
"build_snapshot" : false,
"lucene_version" : "4.8"
},
"tagline" : "You Know, for Search"
}
Thanks in advance
Rakesh

The problem is that you're running ES server v1.2.2 (extremely old version) with a 6.4.0 client.
So the 6.4.0 client has the geoBoundingBoxQuery() method, however the 1.2.2 client provides the geoBoundingBoxFilter() method, both are incompatible. There has been a big query/filter refactor in ES 2.x.
As a rule of thumb you should always run the same version of ES and the client library. In your case, you have a delta of several versions betweem your server and your client.
You should definitely consider upgrading your ES cluster to at least 6.4.0 or downgrade your client to 1.x.

Related

Deserialization for list of objects is not working with Rest Assured Jsonpath and jdk8

I have a Rest Endpoint that returns the below response
{
"incentives": [
{
"incentiveId": "271230",
"effectiveDate": "2022-06-01T07:00:00.000+0000",
"expiryDate": "2022-10-01T03:00:00.000+0000",
"incentiveName": "$500 MAZDA LOYALTY REWARD PROGRAM",
"incentiveAmount": 500,
"incentiveType": "discount",
"disclaimer": ""
},
{
"incentiveId": "271231",
"effectiveDate": "2022-06-01T07:00:00.000+0000",
"expiryDate": "2022-10-01T03:00:00.000+0000",
"incentiveName": "$500 MAZDA MILITARY APPRECIATION BONUS CASH",
"incentiveAmount": 500,
"incentiveType": "discount",
"disclaimer": ""
},
{
"incentiveId": "271229",
"effectiveDate": "2022-06-01T07:00:00.000+0000",
"expiryDate": "2022-07-01T03:00:00.000+0000",
"incentiveName": "MAZDA MOBILITY PROGRAM CASH BONUS",
"incentiveAmount": 1000,
"incentiveType": "discount",
"disclaimer": "Program Period is 6/1/2022 - 6/30/2022."
},
{
"incentiveId": "271242",
"effectiveDate": "2022-06-01T07:00:00.000+0000",
"expiryDate": "2022-07-06T06:59:00.000+0000",
"incentiveName": "$500 MAZDA LEASE TO LEASE LOYALTY REWARD PROGRAM",
"incentiveAmount": 500,
"incentiveType": "discount",
"disclaimer": ""
}
]
}
I am using Rest Assured Jsonpath to deserialize the list of incentives using the below lines of code
JsonPath jsonPathEvaluator = response.jsonPath();
List<Incentive> incentivesList = jsonPathEvaluator.getList("incentives", Incentive.class);
But the above lines of code is throwing the following exception
java.util.ServiceConfigurationError: com.fasterxml.jackson.databind.Module: Provider com.fasterxml.jackson.datatype.jdk8.Jdk8Module not found
at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:593)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(ServiceLoader.java:1219)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1228)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1273)
at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1309)
at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1393)
at com.fasterxml.jackson.databind.ObjectMapper.findModules(ObjectMapper.java:929)
at com.fasterxml.jackson.databind.ObjectMapper.findModules(ObjectMapper.java:912)
at com.fasterxml.jackson.databind.ObjectMapper.findAndRegisterModules(ObjectMapper.java:948)
at io.restassured.path.json.mapper.factory.DefaultJackson2ObjectMapperFactory.create(DefaultJackson2ObjectMapperFactory.java:29)
at io.restassured.path.json.mapper.factory.DefaultJackson2ObjectMapperFactory.create(DefaultJackson2ObjectMapperFactory.java:27)
at io.restassured.common.mapper.factory.ObjectMapperFactory$create.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:148)
at io.restassured.internal.path.json.mapping.JsonPathJackson2ObjectDeserializer.createJackson2ObjectMapper(JsonPathJackson2ObjectDeserializer.groovy:37)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:43)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:193)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:61)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:171)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:194)
at io.restassured.internal.path.json.mapping.JsonPathJackson2ObjectDeserializer.deserialize(JsonPathJackson2ObjectDeserializer.groovy:44)
at io.restassured.path.json.mapping.JsonPathObjectDeserializer$deserialize.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139)
at io.restassured.internal.path.json.mapping.JsonObjectDeserializer.deserializeWithJackson2(JsonObjectDeserializer.groovy:109)
at io.restassured.internal.path.json.mapping.JsonObjectDeserializer$deserializeWithJackson2.callStatic(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:55)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:217)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:240)
at io.restassured.internal.path.json.mapping.JsonObjectDeserializer.deserialize(JsonObjectDeserializer.groovy:70)
at io.restassured.path.json.JsonPath.jsonStringToObject(JsonPath.java:1093)
at io.restassured.path.json.JsonPath.getList(JsonPath.java:400)
Below are the dependencies in my pom.xml file
<!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>5.1.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
<version>2.6.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.6.0</version>
</dependency>
Below is the java version on my machine
java version "1.8.0_333"
Java(TM) SE Runtime Environment (build 1.8.0_333-b02)
Java HotSpot(TM) Client VM (build 25.333-b02, mixed mode, sharing)
Could you please help me understand on what is wrong and on how to resolve this issue?
My issue got solved by adding the below dependency in the pom.xml file, I'm using Java 11 version. The below dependency is used to support JDK8 data types.
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jdk8 -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
<version>2.13.3</version>
</dependency>

ElasticsearchStatusException contains unrecognized parameter: [ccs_minimize_roundtrips]]]

I am trying to do a simple search on ElasticSearch server and getting teh following error
ElasticsearchStatusException[Elasticsearch exception [type=illegal_argument_exception, reason=request [/recordlist1/_search] contains unrecognized parameter: [ccs_minimize_roundtrips]]]
The query String :
{"query":{"match_all":{"boost":1.0}}}
I am using :
elasticsearch-rest-high-level-client (maven artifact)
SearchRequest searchRequest = new SearchRequest(INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(QueryBuilders.matchAllQuery());
searchRequest.source(searchSourceBuilder);
try
{
System.out.print(searchRequest.source());
SearchResponse response = getConnection().search(searchRequest,RequestOptions.DEFAULT);
SearchHit[] results=response.getHits().getHits();
for(SearchHit hit : results)
{
String sourceAsString = hit.getSourceAsString();
System.out.println( gson.fromJson(sourceAsString, Record.class).year);
}
}
catch(ElasticsearchException e)
{
e.getDetailedMessage();
e.printStackTrace();
}
catch (java.io.IOException ex)
{
ex.getLocalizedMessage();
ex.printStackTrace();
}
This usually occurs on porting from elastic-search version 6.X.X to 7.X.X.
You should reduce the elastic-search version to 6.7.1 and try running it.
Since you are using maven you should make sure your dependencies should be like:
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>6.7.1</version>
</dependency>
I ran into this same issue when i had by mistake my 6.5 cluster still running while using the 7.2 API. Once I started up my 7.2 cluster the exception went away.
Problem here is the movement of version, probably you were using elastic search 6.x.x and now using 7.x.x
You can definitely solve this by having your elastic search server of 7.x.x.
Elasticsearch 6.x.x used to have type of document
(where you could give type to your documents)
but Elasticsearch 7.x.x onwards it has no type or
default type _doc, so you need to have _doc as your type
while creating mapping.
Maybe you can find this from stackTrace of exception:
Suppressed: org.elasticsearch.client.ResponseException: method [POST], host [http://127.0.0.1:9200], URI [/recordlist1/_search?rest_total_hits_as_int=true&typed_keys=true&ignore_unavailable=false&expand_wildcards=open%2Cclosed&allow_no_indices=true&ignore_throttled=false&search_type=query_then_fetch&batched_reduce_size=512], status line [HTTP/1.1 400 Bad Request]
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"request [/_search] contains unrecognized parameters: [ignore_throttled], [rest_total_hits_as_int]"}],"type":"illegal_argument_exception","reason":"request [/_search] contains unrecognized parameters: [ignore_throttled], [rest_total_hits_as_int]"},"status":400}
So, You can try this GET method by curl, which come to the same error message.
curl -XGET http://127.0.0.1:9200/recordlist1/_search?rest_total_hits_as_int=true&typed_keys=true&ignore_unavailable=false&expand_wildcards=open%2Cclosed&allow_no_indices=true&ignore_throttled=false&search_type=query_then_fetch&batched_reduce_size=512
I've tried delete 'rest_total_hits_as_int=true' ... Case Closed.
You should check your es-server's version by elasticsearch -V and client’s version in maven.
In high-level client, they add rest_total_hits_as_int=true by default, and I find no access to set it to false.
you can refer to
org.elasticsearch.client.RequestConverters#addSearchRequestParams Line:395 <v6.8.10>
I had no other choice but matching client to match server.
Why it's so Exciting ?
ehn... after all, it is "High Level".

How to use High Level Rest Client in Spring Data ES 3.2.0.M1

Spring Data ES 3.2.0.M1 still uses old TransportClient instead of HighLevelRestClient
Spring Data ES 3.2.0.M1 supports High Level Rest Client, see Add support for Java High Level REST Client. I've added Spring Data ES 3.2.0.M1 to the SB2 app:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>3.2.0.M1</version>
</dependency>
However, still TransportClient is used. There are two indication of that: exceptions on start-up:
o.e.transport.netty4.Netty4Transport : exception caught on transport layer [NettyTcpChannel{localAddress=/127.0.0.1:61171, remoteAddress=localhost/127.0.0.1:8085}], closing connection
io.netty.handler.codec.DecoderException: java.io.StreamCorruptedException: invalid internal transport message format, got (48,54,54,50)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:472) ~[netty-codec-4.1.33.Final.jar:4.1.33.Final]
and exception stacktrace when calling ElasticsearchTemplate:
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:349)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:247)
at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:60)
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:382)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:395)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:384)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:46)
at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.getSearchResponse(ElasticsearchTemplate.java:947)
Are there any config param to tell Spring Data ES to switch to new High Level Rest Client? The docs say nothing about it.
P.S. Spring Data ES 3.2.0.M1 has 6.4.3 ES client version:
Caused by: java.io.StreamCorruptedException: invalid internal transport message format, got (48,54,54,50)
at org.elasticsearch.transport.TcpTransport.validateMessageHeader(TcpTransport.java:1327) ~[elasticsearch-6.4.3.jar:6.4.3]
at org.elasticsearch.transport.netty4.Netty4SizeHeaderFrameDecoder.decode(Netty4SizeHeaderFrameDecoder.java:36) ~[transport-netty4-client-6.4.3.jar:6.4.3]
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:502) ~[netty-codec-4.1.33.Final.jar:4.1.33.Final]
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:441) ~[netty-codec-4.1.33.Final.jar:4.1.33.Final]
... 20 common frames omitted
back-end runs 6.4.2 version:
bash-4.4$ curl http://127.0.0.1:8085
{
"name" : "NA17WWR",
"cluster_name" : "494164851665",
"cluster_uuid" : "7t3LoK7PRp-ur6FyxSmHwQ",
"version" : {
"number" : "6.4.2",
"build_flavor" : "oss",
"build_type" : "zip",
"build_hash" : "04711c2",
"build_date" : "2018-10-16T09:16:35.059415Z",
"build_snapshot" : false,
"lucene_version" : "7.4.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
As mentioned in the issue you're referring to, the high level REST client is available in ElasticsearchRestTemplate (see PR #216) not in ElasticsearchTemplate, which they'll keep until ES 7 for backward compatibility reasons.
You can create one with the configuration below:
<bean name="elasticsearchTemplate"
class="org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate">
<constructor-arg name="client" ref="restClient"/>
</bean>
<elasticsearch:rest-client id="restClient"/>

How to resolve the MSBI dependency error Cannot load class 'com.microsoft.sqlserver.jdbc.SQLServerDriver'?

I have maven based interface, I need to connect MSBI database and fetch the data into mule.
I have added the required jar sqljdbc42.jar to build path.
PFB is the MSBI connection configuration:
<poll doc:name="Poll">
<schedulers:cron-scheduler expression="${msbi.poll.schedule.cdo}"/>
<db:select config-ref="MSBI_Database_Configuration" streaming="true" fetchSize="1000" doc:name="MSBI Select Contact CDO data">
<db:parameterized-query><![CDATA[SELECT [Cstmr_Acct_Id] AS SAP_Account_ID1
,[Accnt_Nm] AS CRM_Account_Name1
,[Accnt_Type] AS APL_Account_Attributes___Account_Type1
,[Cstmr_Sgmnt] AS CRM_Customer_Segment1
,[Trnprttn_role] AS CRM_Transportation_Role1
,CASE WHEN [Accnt_Stts]='A' THEN 'Active' WHEN [Accnt_Stts]='I' THEN 'Inactive' ELSE NULL END AS CRM_Account_Status1
,[Rgn] AS Region1
,[Rgn_desc] AS Region_Text1
,[Clster] AS Cluster1
,[Clster_desc] AS Cluster_Text1
,[Dstrct] AS District1
,[Dstrct_desc] AS District_Text1
,[Cntry] AS Country1
,[Cntry_desc] AS Country_Text1
,[Brnch] AS Branch1
,[Brnch_desc] AS Branch_Text1
,[Trrtry] AS Territory1
,[Trrtry_desc] AS Territory_Desc1
,[New_BT_Cd] AS BT_Code1
,[Lgcy_BT_Cd] AS Legacy_BTCode1
,[Last_Update_Dt] AS LAST_UPDATE_Date1
FROM [dbo].[vw_elqa_CRM_Accnt_Sales_Hierarchy]
WHERE
(
CAST(Last_Update_Dt AS date) >= CAST(GETDATE() AS date) OR
CAST(Last_Update_Dt AS date) >= CAST(#[server.systemProperties['mule.env']=='dev'?server.systemProperties['msbi.debug.csr.query.filterDate']:'2100-01-01'] AS date)
) AND Cstmr_Acct_Id IS NOT NULL]]></db:parameterized-query>
</db:select>
</poll>
When i run the interface it is deployed successfully but while triggering the MSBI throwing below error
ERROR 2017-10-30 20:58:26,792 [nol-integration-v1.3-polling://MSBItoEloquaContactCDODataUpdate/541182371_Worker-1] org.mule.exception.DefaultSystemExceptionStrategy:
********************************************************************************
Message : org.mule.module.db.internal.domain.connection.ConnectionCreationException: Error trying to load driver: com.microsoft.sqlserver.jdbc.SQLServerDriver : Cannot load class 'com.microsoft.sqlserver.jdbc.SQLServerDriver' (java.sql.SQLException)
Element : /MSBI_Database_Configuration # app:bulk-integration.xml:26 (Generic Database Configuration)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.sql.SQLException: Error trying to load driver: com.microsoft.sqlserver.jdbc.SQLServerDriver : Cannot load class 'com.microsoft.sqlserver.jdbc.SQLServerDriver'
at org.enhydra.jdbc.standard.StandardDataSource.getConnection(StandardDataSource.java:184)
at org.enhydra.jdbc.standard.StandardDataSource.getConnection(StandardDataSource.java:144)
at org.mule.module.db.internal.domain.connection.SimpleConnectionFactory.doCreateConnection(SimpleConnectionFactory.java:30)
at org.mule.module.db.internal.domain.connection.AbstractConnectionFactory.create(AbstractConnectionFactory.java:23)
at org.mule.module.db.internal.domain.connection.TransactionalDbConnectionFactory.createDataSourceConnection(TransactionalDbConnectionFactory.java:84)
at org.mule.module.db.internal.domain.connection.TransactionalDbConnectionFactory.createConnection(TransactionalDbConnectionFactory.java:53)
at org.mule.module.db.internal.processor.AbstractDbMessageProcessor.process(AbstractDbMessageProcessor.java:72)
at org.mule.transport.polling.MessageProcessorPollingMessageReceiver$1.process(MessageProcessorPollingMessageReceiver.java:165)
at org.mule.transport.polling.MessageProcessorPollingMessageReceiver$1.process(MessageProcessorPollingMessageReceiver.java:149)
at org.mule.execution.ExecuteCallbackInterceptor.execute(ExecuteCallbackInterceptor.java:16)
at org.mule.execution.CommitTransactionInterceptor.execute(CommitTransactionInterceptor.java:35)
at org.mule.execution.CommitTransactionInterceptor.execute(CommitTransactionInterceptor.java:22)
at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:30)
at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:14)
at org.mule.execution.BeginAndResolveTransactionInterceptor.execute(BeginAndResolveTransactionInterceptor.java:67)
at org.mule.execution.ResolvePreviousTransactionInterceptor.execute(ResolvePreviousTransactionInterceptor.java:44)
at org.mule.execution.SuspendXaTransactionInterceptor.execute(SuspendXaTransactionInterceptor.java:50)
at org.mule.execution.ValidateTransactionalStateInterceptor.execute(ValidateTransactionalStateInterceptor.java:40)
at org.mule.execution.IsolateCurrentTransactionInterceptor.execute(IsolateCurrentTransactionInterceptor.java:41)
at org.mule.execution.ExternalTransactionInterceptor.execute(ExternalTransactionInterceptor.java:48)
at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:28)
at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:13)
at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:110)
at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:30)
at org.mule.transport.polling.MessageProcessorPollingMessageReceiver.pollWith(MessageProcessorPollingMessageReceiver.java:148)
at org.mule.transport.polling.MessageProcessorPollingMessageReceiver.poll(MessageProcessorPollingMessageReceiver.java:139)
at org.mule.transport.AbstractPollingMessageReceiver.performPoll(AbstractPollingMessageReceiver.java:216)
at org.mule.transport.PollingReceiverWorker.poll(PollingReceiverWorker.java:84)
at org.mule.transport.PollingReceiverWorker.run(PollingReceiverWorker.java:48)
at org.mule.modules.schedulers.cron.CronJob.execute(CronJob.java:33)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Getting the below error after adding dependency
ERROR
********************************************************************************
Message : Response code 500 mapped as failure.
Payload : org.glassfish.grizzly.utils.BufferInputStream#cb5d5af
Payload Type : org.mule.module.db.internal.result.resultset.ResultSetIterator
Element : /MSBItoEloquaContactCDODataUpdate/input/0/0/EloquaLookupContactsCDOBulk/subprocessors/1/EloquaLookupFields/subprocessors/0/0/1/2 # nol-integration-v1:bulk-integration.xml:92 (Eloqua Get CDO fields)
Element XML : <http:request config-ref="Eloqua_Bulk_API" path="/customObjects/{customObjectId}/fields" method="GET" doc:name="Eloqua Get CDO fields">
<http:request-builder>
<http:uri-param paramName="customObjectId" value="#[flowVars.cdo.id]"></http:uri-param>
</http:request-builder>
</http:request>
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.module.http.internal.request.ResponseValidatorException: Response code 500 mapped as failure.
at org.mule.module.http.internal.request.SuccessStatusCodeValidator.validate(SuccessStatusCodeValidator.java:37)
at org.mule.module.http.internal.request.DefaultHttpRequester.validateResponse(DefaultHttpRequester.java:413)
at org.mule.module.http.internal.request.DefaultHttpRequester.innerProcess(DefaultHttpRequester.java:401)
at org.mule.module.http.internal.request.DefaultHttpRequester.processBlocking(DefaultHttpRequester.java:221)
at org.mule.processor.AbstractNonBlockingMessageProcessor.process(AbstractNonBlockingMessageProcessor.java:43)
It seems sqljdbc4.jar is not found at runtime.
If you are using Maven build(pom.xml)
Add the dependency to the pom.xml
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
Note :Just for information-
If any jar is not in Maven repo you are referring in your pom.xml , you need to add it yourself to your local repository/company repository.
To add to your local repository,
1.Please check if you are having correct version of driver jar.
2.Execute below to add it to local Maven repository
mvn install:install-file -Dfile=<jar_name>.jar -DgroupId=<group_id_of_jar> -DartifactId=<artifact_id_of_jar> -Dversion=<version_of_jar> -Dpackaging=jar
I'm using Mulesoft, and using the answer above and #Mahesh_Loya's comment, I was able to get this working.
Add dependency to pom.xml, just before closing </dependencies> tag:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
Add the Clojars repo to pom.xml, just before closing </repositories> tag
<repository>
<id>Clojars</id>
<name>Clojars</name>
<url>http://clojars.org/repo/</url>
<layout>default</layout>
</repository>
Save pom.xml and rerun Maven, and all should be working. Happy times.

Elasticsearch 2.0: how to delete by query in Java

I am trying to upgrade to ES 2.0. I have downloaed ES 2.0 and installed it on my Windows machine.
In my pom.xml, I have the following:
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.0.0-rc1</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>delete-by-query</artifactId>
<version>2.0.0-rc1</version>
</dependency>
In my Java code, I did delete by query in the following way when using ES 1.7.3:
StringBuilder b = new StringBuilder("");
b.append("{");
b.append(" \"query\": {");
b.append(" \"term\": {");
b.append(" \"category\": " + category_value );
b.append(" }");
b.append(" }");
b.append("}");
client = getClient();
DeleteByQueryResponse response = client.prepareDeleteByQuery("myindex")
.setTypes("mydocytype")
.setSource(b.toString())
.execute()
.actionGet();
I am hoping to replace this:
DeleteByQueryResponse response = client.prepareDeleteByQuery("myindex")
.setTypes("mydocytype")
.setSource(b.toString())
.execute()
.actionGet();
with ES 2.0 way. Googled but failed to find an example for it. The online API documentation seems too abstract to me. How can I do it?
Another question: Do I have to install delete-by-query plugin in Elasticsearch server?
Thanks for any pointer!
UPDATE
I followed Max's suggestion, and here is what I have now:
First, when create the client, make settings look like the following:
Settings settings = Settings.settingsBuilder()
.put("cluster.name", "mycluster")
.put("plugin.types", DeleteByQueryPlugin.class.getName())
.build();
Second, at the place doing delete-by-query:
DeleteByQueryResponse rsp = new DeleteByQueryRequestBuilder(client, DeleteByQueryAction.INSTANCE)
.setIndices("myindex")
.setTypes("mydoctype")
.setSource(b.toString())
.execute()
.actionGet();
I also installed delete by query plugin by running the following in the root directory of ES:
bin\plugin install delete-by-query
I get errors if I do not install this plugin.
After all these steps, ES related parts work just fine.
plugin.types have been deprecated in ES 2.1.0 (source). So the accepted solution will result in a NullPointerException.
The solution is to use the addPlugin method:
Client client = TransportClient.builder().settings(settings())
.addPlugin(DeleteByQueryPlugin.class)
.build()
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("host",9300));
I believe you can use this:
DeleteByQueryResponse rsp = new DeleteByQueryRequestBuilder(client, DeleteByQueryAction.INSTANCE)
.setTypes("mydocytype")
.setSource(b.toString())
.execute()
.actionGet();
You have to add plugin type to your settings:
Settings settings = Settings.settingsBuilder()
.put("plugin.types", DeleteByQueryPlugin.class.getName())
If you have remote server you have to install the plugin.
From Elastic 5 in onwards...
final BulkIndexByScrollResponse response = DeleteByQueryAction.INSTANCE.newRequestBuilder(super.transportClient)
.filter(
QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery("_type", "MY_TYPE")) // Trick to define and ensure the type.
.must(QueryBuilders.termQuery("...", "...")))
.source("MY_INDEX")
.get();
return response.getDeleted() > 0;
Oficial documentation
firstly:
add elasticsearch-2.3.3/plugins/delete-by-query/delete-by-query-2.3.3.jar to build path.
then:
Client client = TransportClient.builder().settings(settings)
.addPlugin(DeleteByQueryPlugin.class)
.build()
.addTransportAddress(new InetSocketTransportAddress(
InetAddress.getByName("192.168.0.224"), 9300));

Resources