Java Code Examples for org.frameworkset.elasticsearch.client.ClientInterface#getDocument()
The following examples show how to use
org.frameworkset.elasticsearch.client.ClientInterface#getDocument() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ESTest.java From bboss-elasticsearch with Apache License 2.0 | 5 votes |
@Test public void testAddDateDocument() throws ParseException{ testGetmapping(); SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd"); String date = format.format(new Date()); ClientInterface clientUtil = ElasticSearchHelper.getConfigRestClientUtil("estrace/ESTracesMapper.xml"); Demo demo = new Demo(); demo.setDemoId(5l); demo.setAgentStarttime(new Date()); demo.setApplicationName("blackcatdemo"); demo.setContentbody("this is content body"); org.joda.time.format.DateTimeParserBucket s; //创建模板 String response = clientUtil.addDateDocument("demo",//索引表 "demo",//索引类型 "createDemoDocument",//创建文档对应的脚本名称,在estrace/ESTracesMapper.xml中配置 demo); System.out.println("addDateDocument-------------------------"); System.out.println(response); response = clientUtil.getDocument("demo-"+date,//索引表 "demo",//索引类型 "5"); System.out.println("getDocument-------------------------"); System.out.println(response); demo = clientUtil.getDocument("demo-"+date,//索引表 "demo",//索引类型 "5",//创建文档对应的脚本名称,在estrace/ESTracesMapper.xml中配置 Demo.class); }
Example 2
Source File: ESTest.java From elasticsearch-gradle-example with Apache License 2.0 | 5 votes |
public void testAddDateDocument() throws ParseException{ testGetmapping(); SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd"); String date = format.format(new Date()); ClientInterface clientUtil = ElasticSearchHelper.getConfigRestClientUtil("esmapper/estrace/ESTracesMapper.xml"); Demo demo = new Demo(); demo.setDemoId(5l); demo.setAgentStarttime(new Date()); demo.setApplicationName("blackcatdemo"); demo.setContentbody("this is content body"); //创建模板 String response = clientUtil.addDateDocument("demo",//索引表,自动添加日期信息到索引表名称中 "demo",//索引类型 "createDemoDocument",//创建文档对应的脚本名称,在esmapper/estrace/ESTracesMapper.xml中配置 demo); System.out.println("addDateDocument-------------------------"); System.out.println(response); response = clientUtil.getDocument("demo-"+date,//索引表,手动指定日期信息 "demo",//索引类型 "5"); System.out.println("getDocument-------------------------"); System.out.println(response); demo = clientUtil.getDocument("demo-"+date,//索引表 "demo",//索引类型 "5",//创建文档对应的脚本名称,在esmapper/estrace/ESTracesMapper.xml中配置 Demo.class); }
Example 3
Source File: ESTest.java From elasticsearch-gradle-example with Apache License 2.0 | 5 votes |
public void testBulkAddDateDocument() throws ParseException{ testGetmapping(); SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd"); String date = format.format(new Date()); ClientInterface clientUtil = ElasticSearchHelper.getConfigRestClientUtil("esmapper/estrace/ESTracesMapper.xml"); List<Demo> demos = new ArrayList<>(); Demo demo = new Demo(); demo.setDemoId(2l); demo.setAgentStarttime(new Date()); demo.setApplicationName("blackcatdemo2"); demo.setContentbody("this is content body2"); demos.add(demo); demo = new Demo(); demo.setDemoId(3l); demo.setAgentStarttime(new Date()); demo.setApplicationName("blackcatdemo3"); demo.setContentbody("this is content body3"); demos.add(demo); //创建模板 String response = clientUtil.addDateDocuments("demo",//索引表 "demo",//索引类型 "createDemoDocument",//创建文档对应的脚本名称,在esmapper/estrace/ESTracesMapper.xml中配置 demos); System.out.println("addDateDocument-------------------------"); System.out.println(response); response = clientUtil.getDocument("demo-"+date,//索引表 "demo",//索引类型 "2"); System.out.println("getDocument-------------------------"); System.out.println(response); demo = clientUtil.getDocument("demo-"+date,//索引表 "demo",//索引类型 "3",//创建文档对应的脚本名称,在esmapper/estrace/ESTracesMapper.xml中配置 Demo.class); }
Example 4
Source File: ESTest.java From elasticsearch-gradle-example with Apache License 2.0 | 5 votes |
public void testAddDocument() throws ParseException{ testGetmapping(); ClientInterface clientUtil = ElasticSearchHelper.getConfigRestClientUtil("esmapper/estrace/ESTracesMapper.xml"); Demo demo = new Demo(); demo.setDemoId(5l); demo.setAgentStarttime(new Date()); demo.setApplicationName("blackcatdemo"); demo.setContentbody("this is content body"); //创建文档 String response = clientUtil.addDocument("demo",//索引表,自动添加日期信息到索引表名称中 "demo",//索引类型 "createDemoDocument",//创建文档对应的脚本名称,在esmapper/estrace/ESTracesMapper.xml中配置 demo); System.out.println("addDateDocument-------------------------"); System.out.println(response); response = clientUtil.getDocument("demo",//索引表 "demo",//索引类型 "5"); System.out.println("getDocument-------------------------"); System.out.println(response); demo = clientUtil.getDocument("demo",//索引表 "demo",//索引类型 "5",//创建文档对应的脚本名称,在esmapper/estrace/ESTracesMapper.xml中配置 Demo.class); }
Example 5
Source File: ESTest.java From elasticsearch-gradle-example with Apache License 2.0 | 5 votes |
public void testBulkAddDocument() throws ParseException{ testGetmapping(); SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd"); String date = format.format(new Date()); ClientInterface clientUtil = ElasticSearchHelper.getConfigRestClientUtil("esmapper/estrace/ESTracesMapper.xml"); List<Demo> demos = new ArrayList<>(); Demo demo = new Demo(); demo.setDemoId(2l); demo.setAgentStarttime(new Date()); demo.setApplicationName("blackcatdemo2"); demo.setContentbody("this is content body2"); demos.add(demo); demo = new Demo(); demo.setDemoId(3l); demo.setAgentStarttime(new Date()); demo.setApplicationName("blackcatdemo3"); demo.setContentbody("this is content body3"); demos.add(demo); //创建模板 String response = clientUtil.addDateDocuments("demo",//索引表 "demo",//索引类型 "createDemoDocument",//创建文档对应的脚本名称,在esmapper/estrace/ESTracesMapper.xml中配置 demos); System.out.println("addDateDocument-------------------------"); System.out.println(response); response = clientUtil.getDocument("demo-"+date,//索引表 "demo",//索引类型 "2"); System.out.println("getDocument-------------------------"); System.out.println(response); demo = clientUtil.getDocument("demo-"+date,//索引表 "demo",//索引类型 "3",//创建文档对应的脚本名称,在esmapper/estrace/ESTracesMapper.xml中配置 Demo.class); }
Example 6
Source File: ESTest.java From bboss-elasticsearch with Apache License 2.0 | 4 votes |
@Test public void testBulkAddDateDocument() throws ParseException{ testGetmapping(); SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd"); String date = format.format(new Date()); ClientInterface clientUtil = ElasticSearchHelper.getConfigRestClientUtil("estrace/ESTracesMapper.xml"); List<Demo> demos = new ArrayList<Demo>(); Demo demo = new Demo(); demo.setDemoId(2l); demo.setAgentStarttime(new Date()); demo.setApplicationName("blackcatdemo2"); demo.setContentbody("this is content body2"); demos.add(demo); demo = new Demo(); demo.setDemoId(3l); demo.setAgentStarttime(new Date()); demo.setApplicationName("blackcatdemo3"); demo.setContentbody("this is content body3"); demos.add(demo); //创建模板 String response = clientUtil.addDateDocuments("demo",//索引表 "demo",//索引类型 "createDemoDocument",//创建文档对应的脚本名称,在estrace/ESTracesMapper.xml中配置 demos); System.out.println("addDateDocument-------------------------"); System.out.println(response); response = clientUtil.getDocument("demo-"+date,//索引表 "demo",//索引类型 "2"); System.out.println("getDocument-------------------------"); System.out.println(response); demo = clientUtil.getDocument("demo-"+date,//索引表 "demo",//索引类型 "3",//创建文档对应的脚本名称,在estrace/ESTracesMapper.xml中配置 Demo.class); }
Example 7
Source File: PingyinTest.java From elasticsearch-gradle-example with Apache License 2.0 | 4 votes |
@Test public void testBulkAddDocuments() throws ParseException { // testCreateDemoMapping(); ClientInterface clientUtil = ElasticSearchHelper.getRestClientUtil(); List<Demo> demos = new ArrayList<>(); Demo demo = new Demo(); demo.setDemoId(2l); demo.setAgentStarttime(new Date()); demo.setApplicationName("blackcatdemo2"); demo.setContentbody("this is content body2"); demo.setName("刘德华"); demos.add(demo); demo = new Demo(); demo.setDemoId(3l); demo.setAgentStarttime(new Date()); demo.setApplicationName("blackcatdemo3"); demo.setContentbody("四大天王,这种文化很好,中华人民共和国"); demo.setName("张学友"); demos.add(demo); //创建模板 String response = clientUtil.addDocuments("demo",//索引表 "demo",//索引类型 demos); System.out.println("addDocuments-------------------------"); System.out.println(response); //验证创建的两条索引记录 response = clientUtil.getDocument("demo",//索引表 "demo",//索引类型 "2"); System.out.println("getDocument-------------------------"); System.out.println(response); demo = clientUtil.getDocument("demo",//索引表 "demo",//索引类型 "3",//创建文档对应的脚本名称,在esmapper/estrace/ESTracesMapper.xml中配置 Demo.class); }
Example 8
Source File: PingyinTest.java From elasticsearch-gradle-example with Apache License 2.0 | 4 votes |
@Test public void testBulkAddDateDocument1() throws ParseException { // testCreateDemoMapping(); SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd"); String date = format.format(new Date()); ClientInterface clientUtil = ElasticSearchHelper.getRestClientUtil(); List<Demo> demos = new ArrayList<>(); Demo demo = new Demo(); demo.setDemoId(12l); demo.setAgentStarttime(new Date()); demo.setApplicationName("blackcatdemo2"); demo.setContentbody("this is content body2"); demo.setName("liu德华"); demos.add(demo); demo = new Demo(); demo.setDemoId(13l); demo.setAgentStarttime(new Date()); demo.setApplicationName("blackcatdemo3"); demo.setContentbody("四大天王,这种文化很好,中华人民共和国"); demo.setName("zhang学友"); demos.add(demo); //创建模板 String response = clientUtil.addDateDocuments("demo",//索引表 "demo",//索引类型 demos); System.out.println("addDateDocument-------------------------"); System.out.println(response); response = clientUtil.getDocument("demo-"+date,//索引表 "demo",//索引类型 "12"); System.out.println("getDocument-------------------------"); System.out.println(response); demo = clientUtil.getDocument("demo-"+date,//索引表 "demo",//索引类型 "13",//创建文档对应的脚本名称,在esmapper/estrace/ESTracesMapper.xml中配置 Demo.class); }
Example 9
Source File: PingyinTest.java From elasticsearch-gradle-example with Apache License 2.0 | 4 votes |
@Test public void testBulkAddDocument1() throws ParseException { // testCreateDemoMapping(); SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd"); String date = format.format(new Date()); ClientInterface clientUtil = ElasticSearchHelper.getRestClientUtil(); List<Demo> demos = new ArrayList<>(); Demo demo = new Demo(); demo.setDemoId(12l); demo.setAgentStarttime(new Date()); demo.setApplicationName("blackcatdemo2"); demo.setContentbody("this is content body2"); demo.setName("liu德华"); demos.add(demo); demo = new Demo(); demo.setDemoId(13l); demo.setAgentStarttime(new Date()); demo.setApplicationName("blackcatdemo3"); demo.setContentbody("四大天王,这种文化很好,中华人民共和国"); demo.setName("zhang学友"); demos.add(demo); //创建模板 String response = clientUtil.addDateDocuments("demo",//索引表 "demo",//索引类型 demos); System.out.println("addDateDocument-------------------------"); System.out.println(response); response = clientUtil.getDocument("demo-"+date,//索引表 "demo",//索引类型 "12"); System.out.println("getDocument-------------------------"); System.out.println(response); demo = clientUtil.getDocument("demo-"+date,//索引表 "demo",//索引类型 "13",//创建文档对应的脚本名称,在esmapper/estrace/ESTracesMapper.xml中配置 Demo.class); }
Example 10
Source File: DocumentCRUD.java From elasticsearch-gradle-example with Apache License 2.0 | 4 votes |
@Test public void testAddDocument() throws ParseException { // testCreateDemoMapping(); ClientInterface clientUtil = ElasticSearchHelper.getRestClientUtil(); //构建一个对象,日期类型,字符串类型属性演示 Demo demo = new Demo(); demo.setDemoId(2l);//文档id,唯一标识,@PrimaryKey注解标示,如果demoId已经存在做修改操作,否则做添加文档操作 demo.setAgentStarttime(new Date()); demo.setApplicationName("blackcatdemo2"); demo.setContentbody("this is content body2"); demo.setName("刘德华"); //添加或者修改文档,如果demoId已经存在做修改操作,否则做添加文档操作,返回处理结果 String response = clientUtil.addDocument("demo",//索引表 "demo",//索引类型 demo); System.out.println("打印结果:addDocument-------------------------"); System.out.println(response); //根据文档id获取文档对象,返回json报文字符串 response = clientUtil.getDocument("demo",//索引表 "demo",//索引类型 "2");//w System.out.println("打印结果:getDocument-------------------------"); System.out.println(response); //根据文档id获取文档对象,返回Demo对象 demo = clientUtil.getDocument("demo",//索引表 "demo",//索引类型 "2",//文档id Demo.class); //删除文档 clientUtil.deleteDocument("demo",//索引表 "demo",//索引类型 "2");//文档id //批量删除文档 clientUtil.deleteDocuments("demo",//索引表 "demo",//索引类型 new String[]{"2","3"});//批量删除文档ids }
Example 11
Source File: DocumentCRUD.java From elasticsearch-gradle-example with Apache License 2.0 | 4 votes |
@Test public void testBulkAddDocument() throws ParseException { // testCreateDemoMapping(); ClientInterface clientUtil = ElasticSearchHelper.getRestClientUtil(); List<Demo> demos = new ArrayList<>(); Demo demo = new Demo(); demo.setDemoId(2l); demo.setAgentStarttime(new Date()); demo.setApplicationName("blackcatdemo2"); demo.setContentbody("this is content body2"); demo.setName("刘德华"); demos.add(demo); demo = new Demo(); demo.setDemoId(3l); demo.setAgentStarttime(new Date()); demo.setApplicationName("blackcatdemo3"); demo.setContentbody("四大天王,这种文化很好,中华人民共和国"); demo.setName("张学友"); demos.add(demo); //批量添加或者修改文档 String response = clientUtil.addDocuments("demo",//索引表 "demo",//索引类型 demos); System.out.println("addDateDocument-------------------------"); System.out.println(response); response = clientUtil.getDocument("demo",//索引表 "demo",//索引类型 "2");//w System.out.println("getDocument-------------------------"); System.out.println(response); demo = clientUtil.getDocument("demo",//索引表 "demo",//索引类型 "3",//文档id Demo.class); }
Example 12
Source File: SuggestionTest.java From elasticsearch-gradle-example with Apache License 2.0 | 4 votes |
@Test public void testCreateIndex(){ ClientInterface clientUtil = ElasticSearchHelper.getRestClientUtil(); List<Book> demos = new ArrayList<Book>(); Book demo = new Book(); demo.setId(2l); demo.setTitle("scala编程思想"); demo.setMessage("trying out Elasticsearch"); demo.setUser("elastic"); List<SuggestInput> suggest = new ArrayList<>(); SuggestInput input = new SuggestInput(); input.setInput("scala编程思想"); input.setWeight(50); suggest.add(input); input = new SuggestInput(); input.setInput("scala快速入门"); input.setWeight(49); suggest.add(input); input = new SuggestInput(); input.setInput("快学scala"); input.setWeight(49); suggest.add(input); demo.setSuggest(suggest); demos.add(demo); demo = new Book(); demo.setId(3l); demo.setTitle("go圣经"); suggest = new ArrayList<>(); input = new SuggestInput(); input.setInput("go圣经"); input.setWeight(50); suggest.add(input); input = new SuggestInput(); input.setInput("golang"); input.setWeight(49); suggest.add(input); input = new SuggestInput(); input.setInput("go编程思想"); input.setWeight(49); suggest.add(input); demo.setMessage("trying Elasticsearch"); demo.setUser("elastic"); demo.setSuggest(suggest); demos.add(demo); demo = new Book(); demo.setId(4l); demo.setTitle("go编程思想"); suggest = new ArrayList<>(); input = new SuggestInput(); input.setInput("go圣经"); input.setWeight(48); suggest.add(input); input = new SuggestInput(); input.setInput("golang"); input.setWeight(49); suggest.add(input); input = new SuggestInput(); input.setInput("go编程思想"); input.setWeight(50); suggest.add(input); demo.setSuggest(suggest); demo.setMessage("out of Elasticsearch"); demo.setUser("elasticsearch"); demos.add(demo); //创建文档 String response = clientUtil.addDocuments("book",//索引表 "book",//索引类型 demos,"refresh"); System.out.println("addDocuments-------------------------"); System.out.println(response); response = clientUtil.getDocument("book",//索引表 "book",//索引类型 "2"); System.out.println("getDocument-------------------------"); System.out.println(response); demo = clientUtil.getDocument("book",//索引表 "book",//索引类型 "3", Book.class); }