基金产品名称索引设计

 

Here’s the table of contents:

  1. 设计索引
  2. 用CYPHER从MySQL拿数据写入ES

设计索引

{
  "settings": {
    "number_of_replicas": 1,
    "number_of_shards": 3,
    "refresh_interval": "60s",
    "translog": {
      "flush_threshold_size": "1.6gb"
    },
    "merge": {
      "scheduler": {
        "max_thread_count": "1"
      }
    },
    "index": {
      "routing": {
        "allocation": {
          "total_shards_per_node": "2"
        }
      }
    },
    "analysis": {
      "normalizer": {
        "my_normalizer": {
          "type": "custom",
          "filter": [
            "lowercase",
            "asciifolding"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "hcode": {
        "index": true,
        "store": true,
        "type": "keyword"
      },
      "cname": {
         "index": "analyzed"
         "normalizer": "my_normalizer",
         "store": true,
         "type": "keyword"
       },
      "csname": {
         "index": "analyzed"
         "normalizer": "my_normalizer",
         "store": true,
         "type": "keyword"
      }
    }
  }
}

用CYPHER从MySQL拿数据写入ES

// 获取基金CODE
CALL apoc.load.jdbc('jdbc:mysql://testlab-contentdb-dev.crkldnwly6ki.rds.cn-north-1.alibaba.com.cn:3306/analytics_graph_data?user=dev&password=testlabgogo&useUnicode=true&characterEncoding=utf8&serverTimezone=UTC', 'SELECT a.`from` AS hcode FROM (SELECT `from` FROM FUND_HOLD_BOND GROUP BY `from` UNION SELECT `from` FROM FUND_HOLD_STOCK GROUP BY `from`) a GROUP BY a.`from`') YIELD row WITH row.hcode AS hcode
// 获取基金name
CALL apoc.load.jdbc('jdbc:oracle:thin:nfdp/testlabgogo@nfdpdb-sync-prod.crkldnwly6ki.rds.cn-north-1.alibaba.com.cn:1521/ORCL', 'SELECT CNAME,CSNAME FROM INFO.FUND_BASICINFO WHERE FUND_HCODE=?',[hcode]) YIELD row WITH row
// 写入到ES
CALL apoc.es.postRaw('http://10.20.13.130:9200/mstr_fund/_doc/SEC000334680',{hcode:'SEC000334680',cname:'中海可转换债券债券型证券投资基金A类',csname:'中海可转债A'})
CALL apoc.es.post('10.20.13.130:9200','mstr_fund','_doc/SEC000334680',{hcode:'SEC000334680',cname:'中海可转换债券债券型证券投资基金A类',csname:'中海可转债A'},null) yield value
http://10.20.0.157:9200/mstr_fund/_bulk
{"index":{"_id":"SEC000339066"}{}}
{"name":"shechao","hcode":"SEC000339066"}
{"index":{"_id":"SEC000339066"}{}}
{"name":"shechao","hcode":"SEC000339066"}
{hcode:'SEC000334680',cname:'中海可转换债券债券型证券投资基金A类',csname:'中海可转债A'}