优化es,去掉评论权

This commit is contained in:
暮光:城中城
2019-07-16 22:33:42 +08:00
parent cfb954854f
commit bf2bf47f53
11 changed files with 26 additions and 31 deletions

View File

@@ -1,4 +1,4 @@
package com.zyplayer.doc.data.service.elasticsearch.service;
package com.zyplayer.doc.data.service.elasticsearch.entity;
import com.zyplayer.doc.data.service.elasticsearch.support.Document;

View File

@@ -1,6 +1,7 @@
package com.zyplayer.doc.data.service.elasticsearch.service;
import com.zyplayer.doc.data.service.elasticsearch.support.ElaticSearchConfig;
import com.zyplayer.doc.data.service.elasticsearch.entity.EsWikiPage;
import com.zyplayer.doc.data.service.elasticsearch.support.ElasticSearchConfig;
import com.zyplayer.doc.data.service.elasticsearch.support.EsAbstractService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.stereotype.Service;
@@ -11,7 +12,7 @@ import org.springframework.stereotype.Service;
* @since 2019-07-07
*/
@Service
@ConditionalOnBean(ElaticSearchConfig.class)
@ConditionalOnBean(ElasticSearchConfig.class)
public class EsWikiPageService extends EsAbstractService<EsWikiPage> {
@Override

View File

@@ -1,8 +1,3 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.zyplayer.doc.data.service.elasticsearch.support;
import java.lang.annotation.*;

View File

@@ -20,7 +20,7 @@ import java.net.UnknownHostException;
*/
@Configuration
@ConditionalOnProperty(prefix = "zyplayer.doc.manage.elasticsearch", name = "open", havingValue = "true")
public class ElaticSearchConfig {
public class ElasticSearchConfig {
@Value(value = "${zyplayer.doc.manage.elasticsearch.host:''}")
private String host;

View File

@@ -38,7 +38,7 @@ public abstract class EsAbstractService<T> {
private static final Logger logger = LoggerFactory.getLogger(EsAbstractService.class);
@Resource
private TransportClient esClient;
private TransportClient transportClient;
@Resource
private Mapper mapper;
@@ -58,7 +58,7 @@ public abstract class EsAbstractService<T> {
public boolean create(T table) {
String pk = getPrimaryKey(table);
IndexResponse indexResponse = this.esClient
IndexResponse indexResponse = this.transportClient
.prepareIndex(this.getIndexName(), this.getIndexType())
.setId(pk)
.setSource(JSONObject.toJSONString(table), XContentType.JSON)
@@ -69,7 +69,7 @@ public abstract class EsAbstractService<T> {
public boolean update(T table) {
String pk = getPrimaryKey(table);
UpdateResponse updateResponse = this.esClient
UpdateResponse updateResponse = this.transportClient
.prepareUpdate(this.getIndexName(), this.getIndexType(), pk)
.setDoc(JSONObject.toJSONString(table), XContentType.JSON)
.get();
@@ -79,7 +79,7 @@ public abstract class EsAbstractService<T> {
public void delete(T table) {
String pk = getPrimaryKey(table);
DeleteResponse response = this.esClient
DeleteResponse response = this.transportClient
.prepareDelete(this.getIndexName(), this.getIndexType(), pk)
.execute()
.actionGet();
@@ -150,7 +150,7 @@ public abstract class EsAbstractService<T> {
highlightBuilder.preTags("<span style=\"color:red\">");
highlightBuilder.postTags("</span>");
highlightBuilder.field("*");
SearchRequestBuilder requestBuilder = esClient.prepareSearch(this.getIndexName()).setTypes(this.getIndexType())
SearchRequestBuilder requestBuilder = transportClient.prepareSearch(this.getIndexName()).setTypes(this.getIndexType())
.setQuery(queryBuilders)
.highlighter(highlightBuilder)
.setFrom(startIndex).setSize(pageSize).setExplain(true);