indicesD = clientInterface.getIndexes("d*");
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/test/java/org/bboss/elasticsearchtest/index/ReindexTest.java:
--------------------------------------------------------------------------------
1 | package org.bboss.elasticsearchtest.index;
2 | /**
3 | * Copyright 2008 biaoping.yin
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import org.frameworkset.elasticsearch.ElasticSearchHelper;
19 | import org.frameworkset.elasticsearch.client.ClientInterface;
20 | import org.junit.Test;
21 |
22 | /**
23 | *
Description:
24 | *
25 | * Copyright (c) 2018
26 | * @Date 2018/7/25 22:53
27 | * @author biaoping.yin
28 | * @version 1.0
29 | */
30 | public class ReindexTest {
31 | @Test
32 | public void reIndex(){
33 | ClientInterface clientInterface = ElasticSearchHelper.getRestClientUtil();
34 | String response = clientInterface.reindex("demo","newdemo");
35 | System.out.println(response);
36 | response = clientInterface.getIndexMapping("newdemo",true);
37 | System.out.println(response);
38 | long count = clientInterface.countAll("newdemo");
39 | System.out.println(count);
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/java/org/bboss/elasticsearchtest/index/UpdateIndiceMapping.java:
--------------------------------------------------------------------------------
1 | package org.bboss.elasticsearchtest.index;
2 | /**
3 | * Copyright 2020 bboss
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import org.frameworkset.elasticsearch.ElasticSearchHelper;
19 | import org.frameworkset.elasticsearch.client.ClientInterface;
20 | import org.junit.Test;
21 |
22 | /**
23 | *
Description:
24 | *
25 | * Copyright (c) 2020
26 | * @Date 2020/6/1 9:56
27 | * @author biaoping.yin
28 | * @version 1.0
29 | */
30 | public class UpdateIndiceMapping {
31 | @Test
32 | public void testUpdateIndiceMapping(){
33 | ClientInterface clientInterface = ElasticSearchHelper.getConfigRestClientUtil("esmapper/demo7.xml");
34 | if(!clientInterface.isVersionUpper7())
35 |
36 | clientInterface.updateIndiceMapping("/demo/_doc/_mapping","updateDemoIndice");
37 | else{
38 | clientInterface.updateIndiceMapping("/demo/_mapping","updateDemoIndice");//无需指定type
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/org/bboss/elasticsearchtest/jointype/Answer.java:
--------------------------------------------------------------------------------
1 | package org.bboss.elasticsearchtest.jointype;
2 | /**
3 | * Copyright 2008 biaoping.yin
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import com.fasterxml.jackson.annotation.JsonFormat;
19 | import com.fasterxml.jackson.annotation.JsonProperty;
20 | import com.frameworkset.orm.annotation.Column;
21 | import com.frameworkset.orm.annotation.ESId;
22 | import com.frameworkset.orm.annotation.ESRouting;
23 | import org.frameworkset.elasticsearch.entity.ESBaseData;
24 | import org.frameworkset.elasticsearch.entity.JoinSon;
25 |
26 | import java.util.Date;
27 |
28 | /**
29 | *
Description:
30 | *
31 | * Copyright (c) 2018
32 | * @Date 2018/11/22 16:15
33 | * @author biaoping.yin
34 | * @version 1.0
35 | */
36 | public class Answer extends ESBaseData {
37 | @ESId(persistent = true)
38 | private String aid;
39 | private String name;
40 | private String content;
41 | private String person;
42 |
43 | private int datatype;
44 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
45 | @Column(dataformat = "yyyy-MM-dd HH:mm:ss")
46 | @JsonProperty("created_date")
47 | private Date createdDate;
48 | @JsonProperty("question_join")
49 | private JoinSon questionJoin;
50 | @ESRouting
51 | private String routingId;
52 |
53 | public String getName() {
54 | return name;
55 | }
56 |
57 | public void setName(String name) {
58 | this.name = name;
59 | }
60 |
61 | public String getContent() {
62 | return content;
63 | }
64 |
65 | public void setContent(String content) {
66 | this.content = content;
67 | }
68 |
69 | public String getPerson() {
70 | return person;
71 | }
72 |
73 | public void setPerson(String person) {
74 | this.person = person;
75 | }
76 |
77 | public int getDatatype() {
78 | return datatype;
79 | }
80 |
81 | public void setDatatype(int datatype) {
82 | this.datatype = datatype;
83 | }
84 |
85 | public Date getCreatedDate() {
86 | return createdDate;
87 | }
88 |
89 | public void setCreatedDate(Date createdDate) {
90 | this.createdDate = createdDate;
91 | }
92 |
93 | public JoinSon getQuestionJoin() {
94 | return questionJoin;
95 | }
96 |
97 | public void setQuestionJoin(JoinSon questionJoin) {
98 | this.questionJoin = questionJoin;
99 | }
100 |
101 |
102 |
103 | public String getRoutingId() {
104 | return routingId;
105 | }
106 |
107 | public void setRoutingId(String routingId) {
108 | this.routingId = routingId;
109 | }
110 |
111 | public String getAid() {
112 | return aid;
113 | }
114 |
115 | public void setAid(String aid) {
116 | this.aid = aid;
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/src/test/java/org/bboss/elasticsearchtest/jointype/Comment.java:
--------------------------------------------------------------------------------
1 | package org.bboss.elasticsearchtest.jointype;
2 | /**
3 | * Copyright 2008 biaoping.yin
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import com.fasterxml.jackson.annotation.JsonFormat;
19 | import com.fasterxml.jackson.annotation.JsonProperty;
20 | import com.frameworkset.orm.annotation.Column;
21 | import com.frameworkset.orm.annotation.ESId;
22 | import com.frameworkset.orm.annotation.ESRouting;
23 | import org.frameworkset.elasticsearch.entity.ESBaseData;
24 | import org.frameworkset.elasticsearch.entity.JoinSon;
25 |
26 | import java.util.Date;
27 |
28 | /**
29 | *
Description:
30 | *
31 | * Copyright (c) 2018
32 | * @Date 2018/11/22 16:15
33 | * @author biaoping.yin
34 | * @version 1.0
35 | */
36 | public class Comment extends ESBaseData {
37 | @ESId(persistent = true)
38 | private String cid;
39 | private String name;
40 | private String content;
41 | private String person;
42 |
43 | private int datatype;
44 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
45 | @Column(dataformat = "yyyy-MM-dd HH:mm:ss")
46 | @JsonProperty("created_date")
47 | private Date createdDate;
48 | @JsonProperty("question_join")
49 | private JoinSon questionJoin;
50 | @ESRouting
51 | private String routingId;
52 |
53 | public String getName() {
54 | return name;
55 | }
56 |
57 | public void setName(String name) {
58 | this.name = name;
59 | }
60 |
61 | public String getContent() {
62 | return content;
63 | }
64 |
65 | public void setContent(String content) {
66 | this.content = content;
67 | }
68 |
69 | public String getPerson() {
70 | return person;
71 | }
72 |
73 | public void setPerson(String person) {
74 | this.person = person;
75 | }
76 |
77 | public int getDatatype() {
78 | return datatype;
79 | }
80 |
81 | public void setDatatype(int datatype) {
82 | this.datatype = datatype;
83 | }
84 |
85 | public Date getCreatedDate() {
86 | return createdDate;
87 | }
88 |
89 | public void setCreatedDate(Date createdDate) {
90 | this.createdDate = createdDate;
91 | }
92 |
93 | public JoinSon getQuestionJoin() {
94 | return questionJoin;
95 | }
96 |
97 | public void setQuestionJoin(JoinSon questionJoin) {
98 | this.questionJoin = questionJoin;
99 | }
100 |
101 |
102 | public String getCid() {
103 | return cid;
104 | }
105 |
106 | public void setCid(String cid) {
107 | this.cid = cid;
108 | }
109 |
110 | public String getRoutingId() {
111 | return routingId;
112 | }
113 |
114 | public void setRoutingId(String routingId) {
115 | this.routingId = routingId;
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/src/test/java/org/bboss/elasticsearchtest/jointype/Question.java:
--------------------------------------------------------------------------------
1 | package org.bboss.elasticsearchtest.jointype;
2 | /**
3 | * Copyright 2008 biaoping.yin
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import com.fasterxml.jackson.annotation.JsonFormat;
19 | import com.fasterxml.jackson.annotation.JsonProperty;
20 | import com.frameworkset.orm.annotation.Column;
21 | import com.frameworkset.orm.annotation.ESId;
22 | import com.frameworkset.orm.annotation.ESRouting;
23 | import org.frameworkset.elasticsearch.entity.ESBaseData;
24 | import org.frameworkset.elasticsearch.entity.JoinSon;
25 |
26 | import java.util.Date;
27 |
28 | /**
29 | *
Description:
30 | *
31 | * Copyright (c) 2018
32 | * @Date 2018/11/22 16:10
33 | * @author biaoping.yin
34 | * @version 1.0
35 | */
36 | public class Question extends ESBaseData {
37 | @ESId(persistent = true)
38 | private String qid;
39 | private String name;
40 | private String content;
41 | private String person;
42 |
43 | private int datatype;
44 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
45 | @Column(dataformat = "yyyy-MM-dd HH:mm:ss")
46 | @JsonProperty("created_date")
47 | private Date createdDate;
48 | @JsonProperty("question_join")
49 | private JoinSon questionJoin;
50 | @ESRouting
51 | private String routingId;
52 |
53 | public String getName() {
54 | return name;
55 | }
56 |
57 | public void setName(String name) {
58 | this.name = name;
59 | }
60 |
61 | public String getContent() {
62 | return content;
63 | }
64 |
65 | public void setContent(String content) {
66 | this.content = content;
67 | }
68 |
69 | public String getPerson() {
70 | return person;
71 | }
72 |
73 | public void setPerson(String person) {
74 | this.person = person;
75 | }
76 |
77 | public int getDatatype() {
78 | return datatype;
79 | }
80 |
81 | public void setDatatype(int datatype) {
82 | this.datatype = datatype;
83 | }
84 |
85 | public Date getCreatedDate() {
86 | return createdDate;
87 | }
88 |
89 | public void setCreatedDate(Date createdDate) {
90 | this.createdDate = createdDate;
91 | }
92 |
93 | public JoinSon getQuestionJoin() {
94 | return questionJoin;
95 | }
96 |
97 | public void setQuestionJoin(JoinSon questionJoin) {
98 | this.questionJoin = questionJoin;
99 | }
100 |
101 | public String getQid() {
102 | return qid;
103 | }
104 |
105 | public void setQid(String qid) {
106 | this.qid = qid;
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/src/test/java/org/bboss/elasticsearchtest/license/ImportLicense.java:
--------------------------------------------------------------------------------
1 | package org.bboss.elasticsearchtest.license;
2 | /**
3 | * Copyright 2008 biaoping.yin
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import org.frameworkset.elasticsearch.ElasticSearchHelper;
19 | import org.frameworkset.elasticsearch.client.ClientInterface;
20 | import org.frameworkset.elasticsearch.client.ClientUtil;
21 | import org.junit.Test;
22 |
23 | /**
24 | *
Description: import x-pack license
25 | *
26 | * Copyright (c) 2018
27 | * @Date 2018/8/18 23:33
28 | * @author biaoping.yin
29 | * @version 1.0
30 | */
31 | public class ImportLicense {
32 | @Test
33 | public void testLicense(){
34 | ClientInterface clientUtil = ElasticSearchHelper.getConfigRestClientUtil("esmapper/license.xml");
35 |
36 | /**
37 | * Elasticsearch 6.x ,7.x导入license
38 | */
39 | // String ttt = clientUtil.executeHttp("_xpack/license?acknowledge=true","license",ClientUtil.HTTP_PUT);
40 | /**
41 | * Elasticsearch 8.x导入license
42 | */
43 | String ttt = clientUtil.executeHttp("_license?acknowledge=true","license",ClientUtil.HTTP_PUT);
44 |
45 | System.out.println(ttt);
46 | // ttt = clientUtil.createTempate("tracesql_template","traceSQLTemplate");
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/test/java/org/bboss/elasticsearchtest/mapping/MappingTest.java:
--------------------------------------------------------------------------------
1 | package org.bboss.elasticsearchtest.mapping;
2 | /**
3 | * Copyright 2008 biaoping.yin
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import org.frameworkset.elasticsearch.ElasticSearchHelper;
19 | import org.frameworkset.elasticsearch.client.ClientInterface;
20 | import org.frameworkset.elasticsearch.entity.ESIndice;
21 | import org.junit.Test;
22 |
23 | import java.util.List;
24 |
25 | /**
26 | *
Description:
27 | *
28 | * Copyright (c) 2018
29 | * @Date 2018/11/13 9:55
30 | * @author biaoping.yin
31 | * @version 1.0
32 | */
33 | public class MappingTest {
34 | @Test
35 | public void createMapping(){
36 | ClientInterface clientInterface = ElasticSearchHelper.getConfigRestClientUtil("esmapper/arryaymapping.xml");
37 | //从配置文件esmapper/arryaymapping.xml中获取mapping结构,并创建hostagentinfo结构
38 | String result = clientInterface.createIndiceMapping("hostagentinfotest","hostAgentInfoIndice");
39 | System.out.println(result);
40 | }
41 |
42 | @Test
43 | public void deleteMapping(){
44 | ClientInterface clientInterface = ElasticSearchHelper.getRestClientUtil();
45 | //删除mapping结构
46 | String result = clientInterface.dropIndice("hostagentinfotest");
47 | System.out.println(result);
48 | }
49 |
50 | @Test
51 | public void getMapping(){
52 | ClientInterface clientInterface = ElasticSearchHelper.getRestClientUtil();
53 | //获取hostagentinfo的mapping结构
54 | String mapping = clientInterface.getIndexMapping("hostagentinfotest");
55 | System.out.println(mapping);
56 | }
57 |
58 | @Test
59 | public void getAllMapping(){
60 | //获取所有的indice mappings
61 | ClientInterface clientInterface = ElasticSearchHelper.getRestClientUtil();
62 | List mapping = clientInterface.getIndexes();
63 | System.out.println(mapping);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/test/java/org/bboss/elasticsearchtest/parentchild/Company.java:
--------------------------------------------------------------------------------
1 | package org.bboss.elasticsearchtest.parentchild;/*
2 | * Copyright 2008 biaoping.yin
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | import com.frameworkset.orm.annotation.ESId;
18 | import org.frameworkset.elasticsearch.entity.ESBaseData;
19 |
20 | public class Company extends ESBaseData {
21 | private String name;
22 | /**
23 | * 将companyId作为索引_id的值
24 | */
25 | @ESId(readSet = true)
26 | private String companyId;
27 | private String city;
28 | private String country;
29 |
30 | public String getName() {
31 | return name;
32 | }
33 |
34 | public void setName(String name) {
35 | this.name = name;
36 | }
37 |
38 | public String getCity() {
39 | return city;
40 | }
41 |
42 | public void setCity(String city) {
43 | this.city = city;
44 | }
45 |
46 | public String getCountry() {
47 | return country;
48 | }
49 |
50 | public void setCountry(String country) {
51 | this.country = country;
52 | }
53 |
54 | public String getCompanyId() {
55 | return companyId;
56 | }
57 |
58 | public void setCompanyId(String companyId) {
59 | this.companyId = companyId;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/test/java/org/bboss/elasticsearchtest/parentchild/Employee.java:
--------------------------------------------------------------------------------
1 | package org.bboss.elasticsearchtest.parentchild;/*
2 | * Copyright 2008 biaoping.yin
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | import com.fasterxml.jackson.annotation.JsonFormat;
18 | import com.frameworkset.orm.annotation.Column;
19 | import com.frameworkset.orm.annotation.ESId;
20 | import com.frameworkset.orm.annotation.ESParentId;
21 | import org.frameworkset.elasticsearch.entity.ESBaseData;
22 |
23 | import java.util.Date;
24 |
25 | public class Employee extends ESBaseData {
26 | /**
27 | * 通过ESId注解将employeeId指定为雇员的文档_id
28 | */
29 | @ESId
30 | private int employeeId;
31 | /**
32 | * 通过ESParentId注解将companyId指定为雇员的parent属性,对应Company中的文档_id的值
33 | */
34 | @ESParentId
35 | private String companyId;
36 | private String name;
37 | @JsonFormat(pattern = "yyyy-MM-dd")
38 | @Column(dataformat = "yyyy-MM-dd")
39 | private Date birthday;
40 | private String hobby;
41 |
42 |
43 | public String getName() {
44 | return name;
45 | }
46 |
47 | public void setName(String name) {
48 | this.name = name;
49 | }
50 |
51 | public Date getBirthday() {
52 | return birthday;
53 | }
54 |
55 | public void setBirthday(Date birthday) {
56 | this.birthday = birthday;
57 | }
58 |
59 | public String getHobby() {
60 | return hobby;
61 | }
62 |
63 | public void setHobby(String hobby) {
64 | this.hobby = hobby;
65 | }
66 |
67 | public int getEmployeeId() {
68 | return employeeId;
69 | }
70 |
71 | public void setEmployeeId(int employeeId) {
72 | this.employeeId = employeeId;
73 | }
74 |
75 |
76 |
77 | public String getCompanyId() {
78 | return companyId;
79 | }
80 |
81 | public void setCompanyId(String companyId) {
82 | this.companyId = companyId;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/test/java/org/bboss/elasticsearchtest/query/MoreLikeThis.java:
--------------------------------------------------------------------------------
1 | package org.bboss.elasticsearchtest.query;
2 | /**
3 | * Copyright 2008 biaoping.yin
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import org.frameworkset.elasticsearch.ElasticSearchHelper;
19 | import org.frameworkset.elasticsearch.client.ClientInterface;
20 | import org.frameworkset.elasticsearch.entity.ESDatas;
21 | import org.junit.Test;
22 |
23 | import java.util.List;
24 | import java.util.Map;
25 |
26 | /**
27 | *
Description: https://www.elastic.co/guide/en/elasticsearch/reference/7.4/query-dsl-mlt-query.html
28 | *
29 | *
30 | * Copyright (c) 2018
31 | * @Date 2019/12/1 11:30
32 | * @author biaoping.yin
33 | * @version 1.0
34 | */
35 | public class MoreLikeThis {
36 | @Test
37 | public void testMoreLikeThis(){
38 | /**
39 | * {
40 | * "query": {
41 | * "more_like_this" : {
42 | * "fields" : ["title", "description"],
43 | * "like" : "Once upon a time",
44 | * "min_term_freq" : 1,
45 | * "max_query_terms" : 12
46 | * }
47 | * }
48 | * }
49 | */
50 | ClientInterface clientInterface = ElasticSearchHelper.getConfigRestClientUtil("esmapper/morelikethis.xml");
51 | // O/R mapping方式检索,将结果解析为对象类型
52 | ESDatas