Hej,
Chciałbym się was zapytać w jaki sposób powinienem uruchomić elasticsearch w projekcie bo nie bardzo czaje to co jest w dokumentacji opisane. Po za dodaniem zależności oczywiście.
Jak wy to robicie?
Próbuję w poniższy sposób ale IDE krzyczy że "The method get() is undefined for the type IndexRequestBuilder"
package demo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import static org.elasticsearch.common.xcontent.XContentFactory.*;
import java.io.IOException;
import java.util.Date;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.node.Node;
import static org.elasticsearch.node.NodeBuilder.*;
@Controller
@RequestMapping("/greeting")
public class Greeting {
public Node node = nodeBuilder().local(true).node();
public Client client = node.client();
public String response;
@RequestMapping("/index")
public @ResponseBody String index() throws IOException{
String json = "{" +
"\"user\":\"kimchy\"," +
"\"postDate\":\"2013-01-30\"," +
"\"message\":\"trying out Elasticsearch\"" +
"}";
return client.prepareIndex("twitter", "tweet")
.setSource(json).get().toString();
}
}
Pzdr.