Re: failed to get node info...transport.NoNodeAvailableException


(David Pilato) #1

Dis you set a cluster name?

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 21 févr. 2014 à 11:49, "Marwa.g" marwa.ghabri@esprit.tn a écrit :

Hi,
I'm trying to index and search pdf document...I'm using elasticsearch 1.0.0 and elasticsearch-mapper-attachments 2.0.0.RC1 ... I get always these exceptions org.elasticsearch.client.transport.NoNodeAvailableException: No node available[org.elasticsearch.client.transport] [Spidercide] failed to get node info for [#transport#-1][inet[localhost/127.0.0.1:9300]

this is my code :

import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.action.search.SearchRequestBuilder;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.node.Node;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;

public class AttachmentTest {

private Node node;
Client client;
ESLogger log = Loggers.getLogger(AttachmentTest.class);

@BeforeClass
public void setupNode() {

client = new TransportClient().addTransportAddress(new InetSocketTransportAddress("localhost", 9300)); 

}

@Test
public void mapperAttachmentTest() throws Exception {
String idxName = "test";
String idxType = "attachment";
XContentBuilder map = jsonBuilder().startObject()
.startObject(idxType)
.startObject("properties")
.startObject("file")
.field("type", "attachment")
.startObject("fields")
.startObject("title")
.field("store", "yes")
.endObject()
.startObject("file")
.field("term_vector","with_positions_offsets")
.field("store","yes")
.endObject()
.endObject()
.endObject()
.endObject()
.endObject();
try {
client.admin().indices().prepareDelete(idxName).execute().actionGet();
} catch (Exception ex) {}

log.info("create index and mapping"); 
CreateIndexResponse resp = client.admin().indices().prepareCreate(idxName).setSettings( 
        ImmutableSettings.settingsBuilder() 
        .put("number_of_shards", 1) 
        .put("index.numberOfReplicas", 1)) 
        .addMapping("attachment", map).execute().actionGet(); 


String pdfPath = ClassLoader.getSystemResource("isl99201.pdf").getPath(); 

String data64 = org.elasticsearch.common.Base64.encodeFromFile(pdfPath); 


log.info("Indexing"); 
XContentBuilder source = jsonBuilder().startObject() 
        .field("file", data64).endObject(); 

IndexResponse idxResp = client.prepareIndex().setIndex(idxName).setType(idxType).setId("80") 
        .setSource(source).setRefresh(true).execute().actionGet(); 



String queryString = "amplifier"; 


  log.info("Searching by "+queryString); 
  QueryBuilder query = QueryBuilders.queryString(queryString); 

   SearchRequestBuilder searchBuilder = client.prepareSearch().setQuery(query) 
          .addField("title") 
          .addHighlightedField("file"); 

  SearchResponse search = searchBuilder.execute().actionGet(); 
  assertThat(search.hits().totalHits(), equalTo(1L)); 
  assertThat(search.hits().hits().length, equalTo(1)); 
  assertThat(search.hits().getAt(0).highlightFields().get("file"), notNullValue()); 
  assertThat(search.hits().getAt(0).highlightFields().get("file").toString(), containsString("<em>Amplifier</em>")); 

client.close(); 

}
}

and this is what I get:

unning net.hashcode.esattach.AttachmentTest
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNGMapConfigurator@589f2cff
[2014-02-21 11:05:58,484][WARN ][org.elasticsearch.client.transport] [Spidercide] failed to get node info for [#transport#-1][inet[localhost/127.0.0.1:9300]]
org.elasticsearch.transport.NodeDisconnectedException: [][inet[localhost/127.0.0.1:9300]][/cluster/nodes/info] disconnected
[2014-02-21 11:05:58,635][INFO ][org.elasticsearch.net.hashcode.esattach.AttachmentTest] create index and mapping
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 2.111 sec <<< FAILURE!
mapperAttachmentTest(net.hashcode.esattach.AttachmentTest) Time elapsed: 0.123 sec <<< FAILURE!
org.elasticsearch.client.transport.NoNodeAvailableException: No node available
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:170)
at org.elasticsearch.client.transport.support.InternalTransportIndicesAdminClient.create(InternalTransportIndicesAdminClient.java:252)
at org.elasticsearch.client.action.admin.indices.create.CreateIndexRequestBuilder.doExecute(CreateIndexRequestBuilder.java:158)
at org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder.execute(BaseIndicesRequestBuilder.java:52)
at org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder.execute(BaseIndicesRequestBuilder.java:47)
at net.hashcode.esattach.AttachmentTest.mapperAttachmentTest(AttachmentTest.java:64)

Results :

Failed tests: mapperAttachmentTest(net.hashcode.esattach.AttachmentTest): No node available

please could you 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/b18cf109-5e69-4883-9703-696a7e85518f%40googlegroups.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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/D080B826-7869-4484-80FA-29CDCE252BDA%40pilato.fr.
For more options, visit https://groups.google.com/groups/opt_out.


(Binh Ly) #2

Is it possible that your Elasticsearch Java client is a different version
from your Elasticsearch server?

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/b001a75f-3def-4f1d-8c44-3024534e8277%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(marwa.g) #3

Thank you ... I resolved the problem ...I had a mistake in dependency version (pom.xml)


(marwa.g) #4

Thank you ... I resolved the problem ...I had a mistake in dependency
version (pom.xml)

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/155f6c3e-1683-401d-aaf7-8929dc3e2af4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #5