IndexNotFoundException[no such index]
Before querying your facebook index, you need to create it first:
Settings indexSettings = ImmutableSettings.settingsBuilder() .put("number_of_shards", 5) .put("number_of_replicas", 1) .build();CreateIndexRequest indexRequest = new CreateIndexRequest("facebook", indexSettings);client.admin().indices().create(indexRequest).actionGet();
And if you expect to find some results, you need to index your data also:
IndexResponse response = client.prepareIndex("facebook", "Lance", "1") .setSource(jsonBuilder() .startObject() .field("title", "Posting") .field("postDate", new Date()) .field("content", "today's weather is hot") .field("tags", Lists.newArrayList("hashtag")) .endObject() ) .execute() .actionGet();
Then you can search on your index.