rewrite index name
This commit is contained in:
parent
7f8c3051e2
commit
843237db60
|
@ -34,7 +34,7 @@ func (handler APIHandler) HandleAddDocumentAction(w http.ResponseWriter, req *ht
|
||||||
indexName := ps.ByName("index")
|
indexName := ps.ByName("index")
|
||||||
id := ps.ByName("id")
|
id := ps.ByName("id")
|
||||||
if strings.Trim(id, "/") == "" {
|
if strings.Trim(id, "/") == "" {
|
||||||
util.GetUUID()
|
id = util.GetUUID()
|
||||||
}
|
}
|
||||||
_, err = client.Index(indexName, id, reqBody)
|
_, err = client.Index(indexName, id, reqBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -33,7 +33,7 @@ func (handler APIHandler) GetDictListAction(w http.ResponseWriter, req *http.Req
|
||||||
if len(tags) > 3 {
|
if len(tags) > 3 {
|
||||||
tags = tags[0:3]
|
tags = tags[0:3]
|
||||||
}
|
}
|
||||||
rel, err := model2.GetDictList(from, size, name, tags)
|
rel, err := model2.GetDictList(from, size, name, tags, handler.Config.Elasticsearch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
resp["error"] = err
|
resp["error"] = err
|
||||||
resp["status"] = false
|
resp["status"] = false
|
||||||
|
@ -116,29 +116,3 @@ func (handler APIHandler) UpdateDictItemAction(w http.ResponseWriter, req *http.
|
||||||
handler.WriteJSON(w, resp, http.StatusOK)
|
handler.WriteJSON(w, resp, http.StatusOK)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TaskAction handle task creation and return task list which support parameter: `from`, `size` and `host`, eg:
|
|
||||||
//curl -XGET http://127.0.0.1:8001/task?from=100&size=10&host=elasticsearch.cn
|
|
||||||
func (handler APIHandler) TaskAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
|
||||||
|
|
||||||
//fr := handler.GetParameter(req, "from")
|
|
||||||
//si := handler.GetParameter(req, "size")
|
|
||||||
//host := handler.GetParameter(req, "host")
|
|
||||||
//status := handler.GetIntOrDefault(req, "status", -1)
|
|
||||||
//
|
|
||||||
//from, err := strconv.Atoi(fr)
|
|
||||||
//if err != nil {
|
|
||||||
// from = 0
|
|
||||||
//}
|
|
||||||
//size, err := strconv.Atoi(si)
|
|
||||||
//if err != nil {
|
|
||||||
// size = 10
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//orm.Search()
|
|
||||||
//total, tasks, err := model.GetTaskList(from, size, host, status)
|
|
||||||
//if err != nil {
|
|
||||||
// handler.Error(w, err)
|
|
||||||
//} else {
|
|
||||||
// handler.WriteJSONListResult(w, total, tasks, http.StatusOK)
|
|
||||||
}
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ func (handler APIHandler) HandleGetMappingsAction(w http.ResponseWriter, req *ht
|
||||||
}
|
}
|
||||||
if copyAll {
|
if copyAll {
|
||||||
for key, _ := range *idxs {
|
for key, _ := range *idxs {
|
||||||
if strings.HasPrefix(key, ".") {
|
if strings.HasPrefix(key, ".") || strings.HasPrefix(key, "infini-") {
|
||||||
delete(*idxs, key)
|
delete(*idxs, key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,11 @@ func (handler APIHandler) HandleGetMappingsAction(w http.ResponseWriter, req *ht
|
||||||
func (handler APIHandler) HandleGetIndicesAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
func (handler APIHandler) HandleGetIndicesAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
||||||
client := elastic.GetClient(handler.Config.Elasticsearch)
|
client := elastic.GetClient(handler.Config.Elasticsearch)
|
||||||
catIndices, err := client.GetIndices()
|
catIndices, err := client.GetIndices()
|
||||||
|
for key, _ := range *catIndices {
|
||||||
|
if strings.HasPrefix(key,".") || strings.HasPrefix(key, "infini-"){
|
||||||
|
delete(*catIndices, key)
|
||||||
|
}
|
||||||
|
}
|
||||||
resBody := newResponseBody()
|
resBody := newResponseBody()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
resBody["status"] = false
|
resBody["status"] = false
|
||||||
|
|
|
@ -3,6 +3,7 @@ package index_management
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"infini.sh/framework/core/orm"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -76,7 +77,7 @@ func reindex(esName string, body *model.Reindex) (string, error) {
|
||||||
body.Status = model.ReindexStatusRunning
|
body.Status = model.ReindexStatusRunning
|
||||||
body.CreatedAt = time.Now()
|
body.CreatedAt = time.Now()
|
||||||
|
|
||||||
_, err = client.Index("infinireindex", body.ID, body)
|
_, err = client.Index(orm.GetIndexName(body), body.ID, body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -139,7 +140,7 @@ func (handler APIHandler) HandleGetRebuildListAction(w http.ResponseWriter, req
|
||||||
func SyncRebuildResult(esName string) error {
|
func SyncRebuildResult(esName string) error {
|
||||||
client := elastic.GetClient(esName)
|
client := elastic.GetClient(esName)
|
||||||
esBody := fmt.Sprintf(`{"query":{"match":{"status": "%s"}}}`, model.ReindexStatusRunning)
|
esBody := fmt.Sprintf(`{"query":{"match":{"status": "%s"}}}`, model.ReindexStatusRunning)
|
||||||
esRes, err := client.SearchWithRawQueryDSL("infinireindex", []byte(esBody))
|
esRes, err := client.SearchWithRawQueryDSL(orm.GetIndexName(model.Reindex{}), []byte(esBody))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -170,7 +171,7 @@ func SyncRebuildResult(esName string) error {
|
||||||
}
|
}
|
||||||
source["status"] = status
|
source["status"] = status
|
||||||
source["task_source"] = doc.Source
|
source["task_source"] = doc.Source
|
||||||
_, err := client.Index("infinireindex", esRes.Hits.Hits[idMap[doc.ID.(string)]].ID, source)
|
_, err := client.Index(orm.GetIndexName(model.Reindex{}), esRes.Hits.Hits[idMap[doc.ID.(string)]].ID, source)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -197,7 +198,7 @@ func buildTermsQuery(fieldName string, terms []string) string {
|
||||||
func deleteTasksByIds(esName string, terms []string) error {
|
func deleteTasksByIds(esName string, terms []string) error {
|
||||||
client := elastic.GetClient(esName)
|
client := elastic.GetClient(esName)
|
||||||
esBody := buildTermsQuery("_id", terms)
|
esBody := buildTermsQuery("_id", terms)
|
||||||
deleteRes, err := client.DeleteByQuery("infinireindex", []byte(esBody))
|
deleteRes, err := client.DeleteByQuery(orm.GetIndexName(model.Reindex{}), []byte(esBody))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
4
main.go
4
main.go
|
@ -69,8 +69,8 @@ func main() {
|
||||||
module.Start()
|
module.Start()
|
||||||
|
|
||||||
}, func() {
|
}, func() {
|
||||||
orm.RegisterSchema(model.Dict{})
|
orm.RegisterSchemaWithIndexName(model.Dict{}, "infini-dict")
|
||||||
orm.RegisterSchema(model.Reindex{})
|
orm.RegisterSchemaWithIndexName(model.Reindex{}, "infini-reindex")
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"infini.sh/framework/core/elastic"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -18,7 +19,7 @@ type Dict struct {
|
||||||
UpdatedAt time.Time `json:"updated_at" elastic_mapping:"updated_at:{type:date}"`
|
UpdatedAt time.Time `json:"updated_at" elastic_mapping:"updated_at:{type:date}"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDictList(from, size int, name string, tags []string) (orm.Result, error) {
|
func GetDictList(from, size int, name string, tags []string, esName string) (*elastic.SearchResponse, error) {
|
||||||
//sort := []orm.Sort{}
|
//sort := []orm.Sort{}
|
||||||
//sort = append(sort, orm.Sort{Field: "created_at", SortType: orm.DESC})
|
//sort = append(sort, orm.Sort{Field: "created_at", SortType: orm.DESC})
|
||||||
var (
|
var (
|
||||||
|
@ -56,14 +57,10 @@ func GetDictList(from, size int, name string, tags []string) (orm.Result, error)
|
||||||
}
|
}
|
||||||
query = fmt.Sprintf(query, must, should, minShould)
|
query = fmt.Sprintf(query, must, should, minShould)
|
||||||
rq := fmt.Sprintf(`{"from":%d, "size":%d, "sort": %s, "query": %s}`, from, size, sort, query)
|
rq := fmt.Sprintf(`{"from":%d, "size":%d, "sort": %s, "query": %s}`, from, size, sort, query)
|
||||||
//fmt.Println(rq)
|
//q := &orm.Query{
|
||||||
q := &orm.Query{
|
// RawQuery: []byte(rq),
|
||||||
//From: from,
|
//}
|
||||||
//Size: size,
|
//err, sr := orm.Search(Dict{}, nil, q)
|
||||||
//Sort: &sort,
|
client := elastic.GetClient(esName)
|
||||||
RawQuery: []byte(rq),
|
return client.SearchWithRawQueryDSL(orm.GetIndexName(Dict{}), []byte(rq))
|
||||||
}
|
|
||||||
//var dictList = []Dict{}
|
|
||||||
err, sr := orm.Search(Dict{}, nil, q)
|
|
||||||
return sr, err
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"infini.sh/framework/core/orm"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -59,5 +60,5 @@ func GetRebuildList(esName string, from, size int, name string) (*elastic.Search
|
||||||
query = fmt.Sprintf(query, must)
|
query = fmt.Sprintf(query, must)
|
||||||
rq := fmt.Sprintf(`{"from":%d, "size":%d, "sort": %s, "query": %s}`, from, size, sort, query)
|
rq := fmt.Sprintf(`{"from":%d, "size":%d, "sort": %s, "query": %s}`, from, size, sort, query)
|
||||||
client := elastic.GetClient(esName)
|
client := elastic.GetClient(esName)
|
||||||
return client.SearchWithRawQueryDSL("infinireindex", []byte(rq))
|
return client.SearchWithRawQueryDSL(orm.GetIndexName(Reindex{}), []byte(rq))
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,12 @@ export const queryData = {
|
||||||
"hits": {
|
"hits": {
|
||||||
"total": {
|
"total": {
|
||||||
"relation": "eq",
|
"relation": "eq",
|
||||||
"value": 11
|
"value": 12
|
||||||
},
|
},
|
||||||
"max_score": 1,
|
"max_score": 1,
|
||||||
"hits": [
|
"hits": [
|
||||||
{
|
{
|
||||||
"_index": "infini-test",
|
"_index": "test-custom",
|
||||||
"_type": "_doc",
|
"_type": "_doc",
|
||||||
"_id": "jc6_jXYBKoaaPbVfj_8W",
|
"_id": "jc6_jXYBKoaaPbVfj_8W",
|
||||||
"_source": {
|
"_source": {
|
||||||
|
@ -23,7 +23,7 @@ export const queryData = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_index": "infini-test",
|
"_index": "test-custom",
|
||||||
"_type": "_doc",
|
"_type": "_doc",
|
||||||
"_id": "bvhm18dath2d6oa9046g",
|
"_id": "bvhm18dath2d6oa9046g",
|
||||||
"_source": {
|
"_source": {
|
||||||
|
@ -35,7 +35,7 @@ export const queryData = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_index": "infini-test",
|
"_index": "test-custom",
|
||||||
"_type": "_doc",
|
"_type": "_doc",
|
||||||
"_id": "bvhlv6dath2d6oa9045g",
|
"_id": "bvhlv6dath2d6oa9045g",
|
||||||
"_source": {
|
"_source": {
|
||||||
|
@ -47,7 +47,7 @@ export const queryData = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_index": "infini-test",
|
"_index": "test-custom",
|
||||||
"_type": "_doc",
|
"_type": "_doc",
|
||||||
"_id": "bvhltpdath2d6oa90450",
|
"_id": "bvhltpdath2d6oa90450",
|
||||||
"_source": {
|
"_source": {
|
||||||
|
@ -59,20 +59,7 @@ export const queryData = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_index": "infini-test",
|
"_index": "test-custom",
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "js7EjXYBKoaaPbVfvf-c",
|
|
||||||
"_source": {
|
|
||||||
"address": "hunan zhuzhou",
|
|
||||||
"created_at": "2020-12-23T03:59:57.620Z",
|
|
||||||
"email": "cincky@qq.com",
|
|
||||||
"hobbies": "[\"basketball\",\"badminton1\"]",
|
|
||||||
"id": "js7EjXYBKoaaPbVfvf-c",
|
|
||||||
"name": "cincky"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_index": "infini-test",
|
|
||||||
"_type": "_doc",
|
"_type": "_doc",
|
||||||
"_id": "bvi5ellath2e0ukbq5e0",
|
"_id": "bvi5ellath2e0ukbq5e0",
|
||||||
"_source": {
|
"_source": {
|
||||||
|
@ -87,7 +74,7 @@ export const queryData = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_index": "infini-test",
|
"_index": "test-custom",
|
||||||
"_type": "_doc",
|
"_type": "_doc",
|
||||||
"_id": "bvia41lath2eneoeeij0",
|
"_id": "bvia41lath2eneoeeij0",
|
||||||
"_source": {
|
"_source": {
|
||||||
|
@ -101,7 +88,7 @@ export const queryData = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_index": "infini-test",
|
"_index": "test-custom",
|
||||||
"_type": "_doc",
|
"_type": "_doc",
|
||||||
"_id": "bvi5omtath2e0ukbq5eg",
|
"_id": "bvi5omtath2e0ukbq5eg",
|
||||||
"_source": {
|
"_source": {
|
||||||
|
@ -116,7 +103,7 @@ export const queryData = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_index": "infini-test",
|
"_index": "test-custom",
|
||||||
"_type": "_doc",
|
"_type": "_doc",
|
||||||
"_id": "bvhlsptath2d6oa9044g",
|
"_id": "bvhlsptath2d6oa9044g",
|
||||||
"_source": {
|
"_source": {
|
||||||
|
@ -131,7 +118,7 @@ export const queryData = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_index": "infini-test",
|
"_index": "test-custom",
|
||||||
"_type": "_doc",
|
"_type": "_doc",
|
||||||
"_id": "bvhm0d5ath2d6oa90460",
|
"_id": "bvhm0d5ath2d6oa90460",
|
||||||
"_source": {
|
"_source": {
|
||||||
|
@ -145,6 +132,23 @@ export const queryData = {
|
||||||
"id": "bvhm0d5ath2d6oa90460",
|
"id": "bvhm0d5ath2d6oa90460",
|
||||||
"name": "hello2"
|
"name": "hello2"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"_index": "test-custom",
|
||||||
|
"_type": "_doc",
|
||||||
|
"_id": "bvia4ctath2eneoeeijg",
|
||||||
|
"_source": {
|
||||||
|
"address": "beijing",
|
||||||
|
"age": 31,
|
||||||
|
"created_at": "2020-12-23T03:57:57.620Z",
|
||||||
|
"email": "786027438@qq.com",
|
||||||
|
"hobbies": [
|
||||||
|
"basketball1",
|
||||||
|
"badminton"
|
||||||
|
],
|
||||||
|
"id": "bvia4ctath2eneoeeijg",
|
||||||
|
"name": "北京"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ function getUUID(len){
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
'get /_search-center/doc/:index/_search': function(req, res){
|
'post /_search-center/doc/:index/_search': function(req, res){
|
||||||
res.send(queryData)
|
res.send(queryData)
|
||||||
},
|
},
|
||||||
'post /_search-center/doc/:index/_create': function(req, res){
|
'post /_search-center/doc/:index/_create': function(req, res){
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -513,10 +513,10 @@ class Doucment extends React.Component {
|
||||||
//console.log(this.props.document);
|
//console.log(this.props.document);
|
||||||
let clusterIndices = this.props.document.clusterIndices || [];
|
let clusterIndices = this.props.document.clusterIndices || [];
|
||||||
|
|
||||||
clusterIndices = clusterIndices.filter(index => !index.index.startsWith('.')).map((index) =>{
|
clusterIndices = Object.keys(clusterIndices).map((index) =>{
|
||||||
return {
|
return {
|
||||||
label: index.index,
|
label: index,
|
||||||
value: index.index,
|
value: index,
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
const clusters = ["single-es"];
|
const clusters = ["single-es"];
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import {getDocList, saveDoc, deleteDoc, addDoc} from '@/services/doc';
|
import {getDocList, saveDoc, deleteDoc, addDoc} from '@/services/doc';
|
||||||
import {getMappings, getIndices} from '@/services/indices';
|
import {getMappings, getIndices} from '@/services/indices';
|
||||||
import {formatESSearchResult} from '@/utils/utils';
|
import {formatESSearchResult} from '@/utils/elasticsearch';
|
||||||
import { message } from 'antd';
|
import { message } from 'antd';
|
||||||
|
|
||||||
function encodeObjectField(doc){
|
function encodeObjectField(doc){
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import {getRebuildList,reindex, deleteRebuild} from '@/services/rebuild';
|
import {getRebuildList,reindex, deleteRebuild} from '@/services/rebuild';
|
||||||
import { message } from 'antd';
|
import { message } from 'antd';
|
||||||
import {formatESSearchResult} from '@/utils/utils';
|
import {formatESSearchResult} from '@/utils/elasticsearch';
|
||||||
|
|
||||||
|
|
||||||
const delay = (ms) => new Promise((resolve) => {
|
const delay = (ms) => new Promise((resolve) => {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { message } from 'antd';
|
import { message } from 'antd';
|
||||||
import { getDictList, addDict, deleteDict,updateDict } from '@/services/search';
|
import { getDictList, addDict, deleteDict,updateDict } from '@/services/search';
|
||||||
|
import {formatESSearchResult} from '@/utils/elasticsearch';
|
||||||
|
|
||||||
const utf8 = {
|
const utf8 = {
|
||||||
encode: function (string) {
|
encode: function (string) {
|
||||||
|
@ -67,7 +68,9 @@ export default {
|
||||||
message.error(resp.error)
|
message.error(resp.error)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp.payload.Result = resp.payload.Result.map((item)=>{
|
resp.payload = formatESSearchResult(resp.payload);
|
||||||
|
console.log(resp.payload);
|
||||||
|
resp.payload.data = resp.payload.data.map((item)=>{
|
||||||
item.content = utf8.decode(atob(item.content))
|
item.content = utf8.decode(atob(item.content))
|
||||||
return item;
|
return item;
|
||||||
})
|
})
|
||||||
|
@ -78,8 +81,8 @@ export default {
|
||||||
yield put({
|
yield put({
|
||||||
type: 'saveData',
|
type: 'saveData',
|
||||||
payload: {
|
payload: {
|
||||||
dictList: resp.payload.Result,
|
dictList: resp.payload.data,
|
||||||
total: resp.payload.Total,
|
total: resp.payload.total.value,
|
||||||
search: search,
|
search: search,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,14 +18,13 @@ export async function saveDoc(params) {
|
||||||
export async function deleteDoc(params) {
|
export async function deleteDoc(params) {
|
||||||
return request(`${pathPrefix}/doc/${params.index}/${params.data.id}`, {
|
return request(`${pathPrefix}/doc/${params.index}/${params.data.id}`, {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
body: ['testid1', 'testid2'],
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function addDoc(params) {
|
export async function addDoc(params) {
|
||||||
let id = params.data.id || '';
|
let id = params.data.id || '';
|
||||||
delete(params.data, 'id');
|
delete(params.data, 'id');
|
||||||
return request(`${pathPrefix}/doc/${params.index}/${id}`, {
|
return request(`${pathPrefix}/doc/${params.index}/_create`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: params.data,
|
body: params.data,
|
||||||
});
|
});
|
||||||
|
|
|
@ -26,3 +26,25 @@ export function getFields(index, mappings){
|
||||||
|
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function formatESSearchResult(esResp) {
|
||||||
|
const total = esResp.hits.total
|
||||||
|
if(total.value == 0){
|
||||||
|
return {
|
||||||
|
total: total,
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
let dataArr = [];
|
||||||
|
for(let hit of esResp.hits.hits) {
|
||||||
|
if(!hit._source.id){
|
||||||
|
hit._source["id"] = hit._id
|
||||||
|
}
|
||||||
|
hit._source["_index"] = hit._index
|
||||||
|
dataArr.push(hit._source)
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
total: total,
|
||||||
|
data: dataArr,
|
||||||
|
}
|
||||||
|
}
|
|
@ -181,25 +181,3 @@ export function formatWan(val) {
|
||||||
export function isAntdPro() {
|
export function isAntdPro() {
|
||||||
return window.location.hostname === 'preview.pro.ant.design';
|
return window.location.hostname === 'preview.pro.ant.design';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatESSearchResult(esResp) {
|
|
||||||
const total = esResp.hits.total
|
|
||||||
if(esResp.hits.hits.length == 0){
|
|
||||||
return {
|
|
||||||
total: total,
|
|
||||||
data: [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
let dataArr = [];
|
|
||||||
for(let hit of esResp.hits.hits) {
|
|
||||||
if(!hit._source.id){
|
|
||||||
hit._source["id"] = hit._id
|
|
||||||
}
|
|
||||||
hit._source["_index"] = hit._index
|
|
||||||
dataArr.push(hit._source)
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
total: total,
|
|
||||||
data: dataArr,
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue