Created
July 27, 2011 18:42
-
-
Save josephcc/1110065 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package hello; | |
import java.io.IOException; | |
import javax.servlet.http.*; | |
import tcloud.se.service.IndexService; | |
import tcloud.common.stub.RestfulServiceFactory; | |
import java.util.List; | |
import java.util.ArrayList; | |
import tcloud.se.model.*; | |
public class HelloServlet extends HttpServlet { | |
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { | |
response.setContentType("text/plain"); | |
response.getWriter().println("Hello, world"); | |
String yourAccessId = "pub_key"; | |
String yourSecretKey = "priv_key"; | |
String endpoint = "http://api.elasterlabs.com.tw/ws/index"; | |
IndexService indexService = RestfulServiceFactory.getSignaturedService(endpoint, yourAccessId, yourSecretKey, IndexService.class); | |
response.getWriter().println("indexservice" + indexService.toString()); | |
Query myquery = new Query(); | |
myquery.setPattern("*:*"); | |
// myquery.setFieldList(indexService.getIndex("info").getFieldList()); | |
QueryResult result = indexService.queryIndex("info", myquery, 0, 10, "id asc"); | |
response.getWriter().println(result.toString()); | |
response.getWriter().println("queried"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment