Problem with Spring factories for Elasticsearch: "Incorrect settings. You must set esNodes when creating a transport client"

Hi all,
i'm trying to use Spring factories for Elasticsearch in my project, i
delared the different dependency in my pom.xml, and now i whould like to
declare the node and the client in my application-context.xml, so i write
these lines:

<elasticsearch:client id="esClient" />
<elasticsearch:node id="esNode" />
<elasticsearch:client node="esNode" id="esClient" />




localhost:9300
localhost:9301


but when i started the server i have the flowing error, "Incorrect
settings. You must set esNodes when creating a transport client"

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Ammar,

Sounds like you are mixing things here.
If you want to start a node and get a client from that node, just do:
<elasticsearch:node id="esNode" />
<elasticsearch:client node="esNode" id="esClient" />
If you have already a node running outside your spring project and want to use a Transport Client, just do:
<elasticsearch:client id="esClient" />

In your spring file, you tried to define 3 times the esClient bean.

Does it help?

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 4 mars 2013 à 11:24, Ammar Yahia yahia.ammar.info@gmail.com a écrit :

Hi all,
i'm trying to use Spring factories for Elasticsearch in my project, i delared the different dependency in my pom.xml, and now i whould like to declare the node and the client in my application-context.xml, so i write these lines:

<elasticsearch:client id="esClient" />
<elasticsearch:node id="esNode" />
<elasticsearch:client node="esNode" id="esClient" />




localhost:9300
localhost:9301


but when i started the server i have the flowing error, "Incorrect settings. You must set esNodes when creating a transport client"

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

hi david,
thank you, the former problem is solved, I wrote <elasticsearch:node
id="esNode" />

<elasticsearch:client node="esNode" id="esClient" />

, and when I want to use my client, I declare just the following commits ?:

@Autowired
private Client esClient
.........

esClient.prepareSearch()..........

cordially,

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Yes. It should work like this.

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 4 mars 2013 à 12:30, Ammar Yahia yahia.ammar.info@gmail.com a écrit :

hi david,
thank you, the former problem is solved, I wrote <elasticsearch:node id="esNode" />
<elasticsearch:client node="esNode" id="esClient" />

, and when I want to use my client, I declare just the following commits ?:

@Autowired
private Client esClient
.........

esClient.prepareSearch()..........

cordially,

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

i have my class declared us follwing:

public class QueryElasticSearch {

@Autowired
private Client esClient;

public ResponseQuery buildQuery(Query queryS) {
ResponseQuery responseQuery = new ResponseQuery();
responseQuery.setQuery(queryS);
QueryBuilder query = QueryBuilders.queryString(queryS.getKeyword());
SearchResponse searchHits =
esClient.prepareSearch().setIndices("mydocs")...........}

but esClient value is null, is that I must declare otherwise ?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Do you have setter for esClient field?
Did you annotate your class with @Component?
Did you scan your package for annotations?

Something like: https://github.com/dadoonet/spring-elasticsearch/blob/master/src/test/resources/annotation-context.xml

<context:annotation-config />
<context:component-scan base-package="fr.pilato.spring.elasticsearch.annotation" />

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 4 mars 2013 à 14:40, Ammar Yahia yahia.ammar.info@gmail.com a écrit :

i have my class declared us follwing:

public class QueryElasticSearch {

@Autowired
private Client esClient;

public ResponseQuery buildQuery(Query queryS) {
ResponseQuery responseQuery = new ResponseQuery();
responseQuery.setQuery(queryS);
QueryBuilder query = QueryBuilders.queryString(queryS.getKeyword());
SearchResponse searchHits = esClient.prepareSearch().setIndices("mydocs")...........}

but esClient value is null, is that I must declare otherwise ?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

it works, I have not been paying attention when calling my class
QueryElasticSearch that
contains the field client, I made a simple instantiation of my class
instead of going through spring for my class instantiation,

Thanks a lot David,

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi All,
ihave facing problem with this exception

org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'esNode' defined in class path resource
[com/newwave/dc/elasticsearch/annotation/AppConfig.class]: No matching
factory method found: factory bean 'appConfig'; factory method 'esNode()'.
Check that a method with the specified name exists and that it is
non-static.

can anyone help me.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi,

Sounds like you want to only use annotations and not the xml spring files, don't you?
If so, you have to define a method named esNode() in your AppConfig class.

Have a look here: https://github.com/scrutmydocs/scrutmydocs/blob/master/src/main/java/org/scrutmydocs/webapp/configuration/AppConfig.java#L56

Does it help?

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 6 mars 2013 à 08:03, srikanth gone srikanthg93@gmail.com a écrit :

Hi All,
ihave facing problem with this exception

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'esNode' defined in class path resource [com/newwave/dc/elasticsearch/annotation/AppConfig.class]: No matching factory method found: factory bean 'appConfig'; factory method 'esNode()'. Check that a method with the specified name exists and that it is non-static.

can anyone help me.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

you can have a look at Spring data elasticsearch !https://github.com/BioMedCentralLtd/spring-data-elasticsearch

On Monday, 4 March 2013 10:24:43 UTC, Ammar Yahia wrote:

Hi all,
i'm trying to use Spring factories for Elasticsearch in my project, i
delared the different dependency in my pom.xml, and now i whould like to
declare the node and the client in my application-context.xml, so i write
these lines:

<elasticsearch:client id="esClient" />
<elasticsearch:node id="esNode" />
<elasticsearch:client node="esNode" id="esClient" />

<bean id="esClient"

class="fr.pilato.spring.elasticsearch.ElasticsearchTransportClientFactoryBean">


localhost:9300
localhost:9301


but when i started the server i have the flowing error, "Incorrect
settings. You must set esNodes when creating a transport client"

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi David,

I have used these two tags in applicationcontext.xml

<elasticsearch:client id="esClient" />

<elasticsearch:client node="esNode" id="esClient" />

i am getting this log..

18:08:50,265 DEBUG [ElasticsearchNodeFactoryBean] Starting ElasticSearch node...
18:08:52,843 INFO [ElasticsearchNodeFactoryBean] Node [junit.node] for [junit.cluster] cluster started...
18:08:52,843 DEBUG [ElasticsearchNodeFactoryBean] - data : /es/twitter
18:08:52,843 DEBUG [ElasticsearchNodeFactoryBean] - logs : D:/ProgramFiles/Apache Software Foundation/Tomcat 5.5/logs
18:08:52,875 INFO [ElasticsearchClientFactoryBean] Starting ElasticSearch client
18:08:52,875 DEBUG [ElasticsearchClientFactoryBean] Automatic discovery is activated. Looking for definition files in classpath under /es.
18:08:52,875 DEBUG [ElasticsearchClientFactoryBean] Automatic discovery found twitter/tweet json file in classpath under /es.
18:08:52,890 TRACE [ElasticsearchClientFactoryBean] createIndex(twitter)
18:08:52,890 DEBUG [ElasticsearchClientFactoryBean] Index twitter doesn't exist. Creating it.
18:08:52,890 TRACE [ElasticsearchClientFactoryBean] Found settings for index twitter : { "index" : { "number_of_shards" : 3, "number_of_replicas" : 2 }}
18:08:53,593 TRACE [ElasticsearchClientFactoryBean] /createIndex(twitter)
18:08:53,593 TRACE [ElasticsearchClientFactoryBean] pushMapping(twitter,tweet,false)
18:08:53,593 DEBUG [ElasticsearchClientFactoryBean] Mapping [twitter]/[tweet] doesn't exist. Creating it.
18:08:53,593 TRACE [ElasticsearchClientFactoryBean] Mapping for [twitter]/[tweet]={ "tweet" : { "properties" : { "message" : {"type" : "string", "store" : "yes"} } }}
18:08:53,953 DEBUG [ElasticsearchClientFactoryBean] Mapping definition for [twitter]/[tweet] succesfully created.
18:08:53,953 TRACE [ElasticsearchClientFactoryBean] /pushMapping(twitter,tweet,false)
18:08:56,937 ERROR [DispatcherServlet] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'esNode' defined in class path resource [com/newwave/dc/elasticsearch/annotation/AppConfig.class]: No matching factory method found: factory bean 'appConfig'; factory method 'esNode()'. Check that a method with the specified name exists and that it is non-static.

this is AppConfig Class

@Configuration
public class AppConfig {

@Bean
public Node esNode() throws Exception {
	ElasticsearchNodeFactoryBean factory = new ElasticsearchNodeFactoryBean();
	factory.afterPropertiesSet();
	return factory.getObject();
}

@Bean
public Client esClient() throws Exception {
	ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
	factory.setNode(esNode());
	factory.afterPropertiesSet();
	return factory.getObject();
	}

}

is there any mixing things?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Don't add the both ways of creating Node and Client.
Use AppConfig or beans in applicationContext.xml.

I would say, remove you AppConfig class (or at least remove @Configuration annotation for your test).

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 6 mars 2013 à 13:47, srikanth gone srikanthg93@gmail.com a écrit :

Hi David,

I have used these two tags in applicationcontext.xml

<elasticsearch:client id="esClient" />

<elasticsearch:client node="esNode" id="esClient" />

i am getting this log..

18:08:50,265 DEBUG [ElasticsearchNodeFactoryBean] Starting Elasticsearch node...
18:08:52,843 INFO [ElasticsearchNodeFactoryBean] Node [junit.node] for [junit.cluster] cluster started...
18:08:52,843 DEBUG [ElasticsearchNodeFactoryBean] - data : /es/twitter
18:08:52,843 DEBUG [ElasticsearchNodeFactoryBean] - logs : D:/ProgramFiles/Apache Software Foundation/Tomcat 5.5/logs
18:08:52,875 INFO [ElasticsearchClientFactoryBean] Starting Elasticsearch client
18:08:52,875 DEBUG [ElasticsearchClientFactoryBean] Automatic discovery is activated. Looking for definition files in classpath under /es.
18:08:52,875 DEBUG [ElasticsearchClientFactoryBean] Automatic discovery found twitter/tweet json file in classpath under /es.
18:08:52,890 TRACE [ElasticsearchClientFactoryBean] createIndex(twitter)
18:08:52,890 DEBUG [ElasticsearchClientFactoryBean] Index twitter doesn't exist. Creating it.
18:08:52,890 TRACE [ElasticsearchClientFactoryBean] Found settings for index twitter : { "index" : { "number_of_shards" : 3, "number_of_replicas" : 2 }}
18:08:53,593 TRACE [ElasticsearchClientFactoryBean] /createIndex(twitter)
18:08:53,593 TRACE [ElasticsearchClientFactoryBean] pushMapping(twitter,tweet,false)
18:08:53,593 DEBUG [ElasticsearchClientFactoryBean] Mapping [twitter]/[tweet] doesn't exist. Creating it.
18:08:53,593 TRACE [ElasticsearchClientFactoryBean] Mapping for [twitter]/[tweet]={ "tweet" : { "properties" : { "message" : {"type" : "string", "store" : "yes"} } }}
18:08:53,953 DEBUG [ElasticsearchClientFactoryBean] Mapping definition for [twitter]/[tweet] succesfully created.
18:08:53,953 TRACE [ElasticsearchClientFactoryBean] /pushMapping(twitter,tweet,false)
18:08:56,937 ERROR [DispatcherServlet] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'esNode' defined in class path resource [com/newwave/dc/elasticsearch/annotation/AppConfig.class]: No matching factory method found: factory bean 'appConfig'; factory method 'esNode()'. Check that a method with the specified name exists and that it is non-static.

this is AppConfig Class

@Configuration
public class AppConfig {

@Bean
public Node esNode() throws Exception {
ElasticsearchNodeFactoryBean factory = new ElasticsearchNodeFactoryBean();
factory.afterPropertiesSet();
return factory.getObject();
}

@Bean
public Client esClient() throws Exception {
ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
factory.setNode(esNode());
factory.afterPropertiesSet();
return factory.getObject();
}

}

is there any mixing things?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi David,

thank you, issue resolved.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.