国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

canaladapter 同步mysql(一對(duì)多關(guān)系)到es,es 添加逗號(hào)分詞查詢

這篇具有很好參考價(jià)值的文章主要介紹了canaladapter 同步mysql(一對(duì)多關(guān)系)到es,es 添加逗號(hào)分詞查詢。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

mysql 一對(duì)多關(guān)系同步到es,剛好es需要的是一個(gè)字段對(duì)應(yīng)逗號(hào)分割的值。這樣就解決了mysql多表關(guān)聯(lián)查詢很慢的弊端。但是es中給如何把逗號(hào)分割的字符串做為查詢條件呢,答案如下:先看一個(gè)簡(jiǎn)單的例子:

添加一個(gè)逗號(hào)分詞

PUT info-flow-test4
{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_anal": {
          "type": "pattern",
          "pattern": ","
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "id": {
        "type": "keyword"
      },
      "content_id": {
        "type": "long"
      },
      "content_type": {
        "type": "integer"
      },
      "tags": {
        "type": "text",
        "analyzer": "my_anal"
      }
    }
  }
}
添加一個(gè)文檔
POST /info-flow-test4/_doc
{
  "tags": "1,2,33"
}

POST /info-flow-test4/_search
{
  "query": {
    "match": {
      "tags": "2"
    }
  }
}
返回結(jié)果:
{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 0.2876821,
    "hits" : [
      {
        "_index" : "info-flow-test4",
        "_type" : "_doc",
        "_id" : "MUFNDX8BciPKIrWg9Qc6",
        "_score" : 0.2876821,
        "_source" : {
          "tags" : "1,2,33"
        }
      }
    ]
  }
}

canaladapter 同步mysql(一對(duì)多關(guān)系)到es,es 添加逗號(hào)分詞查詢,canal,elasticsearch,大數(shù)據(jù),搜索引擎

?

以上就是逗號(hào)分割的字段如何在es中檢索出來。

項(xiàng)目中實(shí)戰(zhàn):通過canaladapter 同步一對(duì)多的關(guān)系到es, canaladapter配置文件如下:

dataSourceKey: defaultDS
destination: canalserver
outerAdapterKey: essync
groupId: g1
esMapping:
  _index: wx_cp_user_contact_rel_all
  _id: id
  #  upsert: true
  #  pk: id
  sql: "select
                	CONCAT(a.corp_id, '_', a.follow_user_id, '_', a.external_userid) as id,
                	a.external_userid,
                	a.follow_user_id,
                	a.follow_user_remark,
                	a.follow_user_description ,
                	date_format( a.follow_user_createtime, '%Y-%m-%d %H:%I:%S') as follow_user_createtime,
                	a.follow_user_tags_group_name,
                	a.follow_user_tags_tag_name ,
                	a.follow_user_tags_type ,
                	a.follow_user_remark_corp_name ,
                	a.address,
                	a.corp_id ,
                	a.follow_user_remark_mobiles ,
                	a.follow_user_state ,
                	a.status ,
                	a. birthday,
                	date_format( a.link_time, '%Y-%m-%d %H:%I:%S') as link_time,
                	date_format( a.create_time, '%Y-%m-%d %H:%I:%S') as create_time,
                	a.follow_user_add_way,
                	b.name,
                	b.avatar,
                	b.type,
                	b.gender,
                	b.unionid,
                	b.position,
                	b.corp_name ,
                	b.corp_full_name,
                	b.external_profile,
                	b.phone,
                	d.broadband_umber,
                	e.mobile,
                	f.tags
                from
                	wx_cp_user_contact_rel a
                left join wx_cp_user_contact b on	a.external_userid = b.external_userid	and a.corp_id = b.corp_id
                left join wx_cp_user_contact_ext_rel d on a.external_userid = d.external_userid	and a.follow_user_id = d.user_id and a.corp_id = d.corp_id
                left join wx_cp_user e on  e.user_id = a.follow_user_id and e.corp_id = a.corp_id
                left join (select ec_user_id ,user_id , GROUP_CONCAT(tag_id) as tags,corp_id from wx_cp_user_contact_tag_rel  group by ec_user_id,user_id,corp_id) f on   a.external_userid = f.ec_user_id	and a.follow_user_id = f.user_id and a.corp_id = f.corp_id
"
  #  objFields:
  #    _labels: array:;
  etlCondition: "where a.corp_id ={}"
  commitBatch: 3000

es索引建立:

PUT wx_cp_user_contact_rel_all/
 {
    "settings": {
    "analysis": {
      "analyzer": {
        "my_anal": {
          "type": "pattern",
          "pattern": ","
        }
      }
    }
  },
    "mappings" : {
      "properties" : {
        "address" : {
          "type" : "text",
          "analyzer" : "ik_max_word"
        },
        "avatar" : {
          "type" : "keyword"
        },
        "birthday" : {
          "type" : "date",
          "format" : "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd HH:mm:ss.S||strict_date_optional_time||epoch_millis"
        },
        "broadband_umber" : {
          "type" : "keyword"
        },
        "corp_full_name" : {
          "type" : "text",
          "analyzer" : "ik_max_word"
        },
        "corp_id" : {
          "type" : "keyword"
        },
        "corp_name" : {
          "type" : "text",
          "analyzer" : "ik_max_word"
        },
        "create_time" : {
          "type" : "date",
          "format" : "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd HH:mm:ss.S||strict_date_optional_time||epoch_millis"
        },
        "develop_phone" : {
          "type" : "keyword"
        },
        "external_profile" : {
          "type" : "text",
          "analyzer" : "ik_max_word"
        },
        "external_userid" : {
          "type" : "keyword"
        },
        "follow_user_add_way" : {
          "type" : "keyword"
        },
        "follow_user_createtime" : {
          "type" : "date",
          "format" : "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd HH:mm:ss.S||strict_date_optional_time||epoch_millis"
        },
        "follow_user_description" : {
          "type" : "text",
          "analyzer" : "ik_max_word"
        },
        "follow_user_id" : {
          "type" : "keyword"
        },
        "follow_user_remark" : {
          "type" : "text",
          "analyzer" : "ik_max_word"
        },
        "follow_user_remark_corp_name" : {
          "type" : "text",
          "analyzer" : "ik_max_word"
        },
        "follow_user_remark_iop_mobiles" : {
          "type" : "keyword"
        },
        "follow_user_remark_mobiles" : {
          "type" : "keyword"
        },
        "follow_user_state" : {
          "type" : "keyword"
        },
        "follow_user_tags_group_name" : {
          "type" : "keyword"
        },
        "follow_user_tags_tag_name" : {
          "type" : "keyword"
        },
        "follow_user_tags_type" : {
          "type" : "keyword"
        },
        "gender" : {
          "type" : "integer"
        },
        "is_has_tag" : {
          "type" : "integer"
        },
        "job_number" : {
          "type" : "keyword"
        },
        "link_time" : {
          "type" : "date",
          "format" : "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd HH:mm:ss.S||strict_date_optional_time||epoch_millis"
        },
        "mobile_update_time" : {
          "type" : "date",
          "format" : "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd HH:mm:ss.S||strict_date_optional_time||epoch_millis"
        },
        "name" : {
          "type" : "keyword"
        },
        "phone" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "position" : {
          "type" : "keyword"
        },
        "status" : {
          "type" : "short"
        },
        "type" : {
          "type" : "integer"
        },
        "unionid" : {
          "type" : "keyword"
        },
        "unionid_mobile" : {
          "type" : "keyword"
        },
        "update_time" : {
          "type" : "date",
          "format" : "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd HH:mm:ss.S||strict_date_optional_time||epoch_millis"
        },
        "user_code" : {
          "type" : "keyword"
        },
         "mobile" : {
          "type" : "keyword"
        },
         "tags": {
        "type": "text",
        "analyzer": "my_anal"
      }
      }
    }
  }

項(xiàng)目中 員工給客戶大的標(biāo)簽,是一對(duì)多的關(guān)系,但是為了在es中能對(duì)標(biāo)簽做完檢索條件。不得已才有此方案,重點(diǎn)關(guān)注上次 tags 字段(完結(jié))文章來源地址http://www.zghlxwxcb.cn/news/detail-587505.html

到了這里,關(guān)于canaladapter 同步mysql(一對(duì)多關(guān)系)到es,es 添加逗號(hào)分詞查詢的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • Elasticsearch實(shí)戰(zhàn)(二十二)---ES數(shù)據(jù)建模與Mysql對(duì)比 一對(duì)一模型

    我們?nèi)绾伟袽ysql的模型合理的在ES中去實(shí)現(xiàn)? 就需要你對(duì)要存儲(chǔ)的數(shù)據(jù)足夠的了解,及對(duì)應(yīng)用場(chǎng)景足夠的深入分析,才能建立一個(gè)合適的模型,便于你后期擴(kuò)展 實(shí)體之間的關(guān)系: 一對(duì)一 模型 一對(duì)一(1:1):一個(gè)實(shí)體最多只能能另一個(gè)實(shí)體相關(guān)聯(lián),另一個(gè)實(shí)體如是。 例:一個(gè)只能

    2024年02月10日
    瀏覽(18)
  • es elasticsearch 十 中文分詞器ik分詞器 Mysql 熱更新詞庫

    es elasticsearch 十 中文分詞器ik分詞器 Mysql 熱更新詞庫

    目錄 中文分詞器ik分詞器 介紹 安裝 使用分詞器 Ik分詞器配置文件 Mysql 熱更新詞庫 介紹 中文分詞器按照中文進(jìn)行分詞,中文應(yīng)用最廣泛的是ik分詞器 安裝 官網(wǎng)下載對(duì)應(yīng)版本zip 下載 ?放到 ?plugins 目錄 新建 ik文件夾 考入解析zip 重啟 es //分成小單詞 使用分詞器 ik_max_word分成

    2024年02月07日
    瀏覽(21)
  • 如何玩mysql5.7實(shí)現(xiàn)分詞查詢,來實(shí)現(xiàn)類似ES的效果

    背景:在做海外主數(shù)據(jù)項(xiàng)目的時(shí)候,PM提出了一個(gè)需求,說是類似于搜索的功能。但是需要實(shí)現(xiàn)根據(jù)輸入的字符串進(jìn)行相似度的查詢,并且計(jì)算出輸入的字符串與查出的字符串的相似度是多少。 思考:第一次聽到需求的時(shí)候感覺還挺簡(jiǎn)單的,以為不就是個(gè)迷糊查詢嗎?但仔細(xì)

    2024年02月01日
    瀏覽(21)
  • Mysql和ES、Redis數(shù)據(jù)同步方案匯總_redis同步數(shù)據(jù)從mysql到es

    Mysql和ES、Redis數(shù)據(jù)同步方案匯總_redis同步數(shù)據(jù)從mysql到es

    文章目錄 前言 一、數(shù)據(jù)同步方案 1.同步雙寫 [2.異步雙寫(MQ方式)](#2MQhttpssocsdnnetsosearchqMQspm1001210130017020_53) 3.基于Mysql表定時(shí)掃描同步 [4.基于Binlog實(shí)時(shí)同步](#4BinloghttpssocsdnnetsosearchqBinlogspm1001210130017020_119) [二、數(shù)據(jù)遷移同步工具選型](#httpssocsdnnetsosearchqspm1001210130017020_141) 總結(jié)

    2024年04月23日
    瀏覽(26)
  • MyBatis 的關(guān)聯(lián)關(guān)系配置 一對(duì)多,一對(duì)一,多對(duì)多 關(guān)系的映射處理

    MyBatis 的關(guān)聯(lián)關(guān)系配置 一對(duì)多,一對(duì)一,多對(duì)多 關(guān)系的映射處理

    目錄 一.關(guān)聯(lián)關(guān)系配置的好處 ?二.?導(dǎo)入數(shù)據(jù)庫表: ?三.? ? 一對(duì)多關(guān)系:--? ? 一個(gè)訂單對(duì)應(yīng)多個(gè)訂單項(xiàng)? ? ? ? 四.一對(duì)一關(guān)系:---一個(gè)訂單項(xiàng)對(duì)應(yīng)一個(gè)訂單 五.多對(duì)多關(guān)系(兩個(gè)一對(duì)多) ?????????MyBatis是一個(gè)Java持久化框架,可以 通過XML或注解的方式 將對(duì)象與數(shù)據(jù)庫

    2024年02月11日
    瀏覽(26)
  • MySQL同步ES方案

    MySQL同步ES方案

    在項(xiàng)目開發(fā)中,我們經(jīng)常將 MySQL 作為業(yè)務(wù)數(shù)據(jù)庫,ES 作為查詢數(shù)據(jù)庫,用來實(shí)現(xiàn)讀寫分離,緩解 MySQL 數(shù)據(jù)庫的查詢壓力,應(yīng)對(duì)海量數(shù)據(jù)的復(fù)雜查詢。 這其中有一個(gè)很重要的問題,就是如何實(shí)現(xiàn) MySQL 數(shù)據(jù)庫和 ES 的數(shù)據(jù)同步,今天和大家聊聊 MySQL 和 ES 數(shù)據(jù)同步的各種方案。

    2024年04月11日
    瀏覽(24)
  • 4種 MySQL 同步 ES 方案

    4種 MySQL 同步 ES 方案

    數(shù)據(jù)同步是一個(gè)很常見的業(yè)務(wù)場(chǎng)景。本文會(huì)講述數(shù)據(jù)同步的 4 種方案,并給出常用數(shù)據(jù)遷移工具,干貨滿滿! 在實(shí)際項(xiàng)目開發(fā)中,我們經(jīng)常將 MySQL 作為業(yè)務(wù)數(shù)據(jù)庫,ES 作為查詢數(shù)據(jù)庫,用來實(shí)現(xiàn)讀寫分離,緩解 MySQL 數(shù)據(jù)庫的查詢壓力,應(yīng)對(duì)海量數(shù)據(jù)的復(fù)雜查詢。 這其中有一

    2024年02月08日
    瀏覽(25)
  • Datax同步MySQL到ES

    Datax同步MySQL到ES

    建表語句 插入數(shù)據(jù) 建立索引語句 我這里使用Kibana工具連接ES進(jìn)行操作的,也可以使用Postman進(jìn)行操作 Kibana操作語句 Postman操作語句 地址輸入 Json文本輸入 當(dāng)出現(xiàn)以下信息代表創(chuàng)建索引成功 參數(shù)介紹 reader:datax的source(來源)端 reader.cloumn::讀取mysql的字段名 reader.connection.jdbcU

    2024年02月13日
    瀏覽(18)
  • logstash同步mysql數(shù)據(jù)到es(三、es模板問題)

    ?相關(guān)問題匯總: logstash同步mysql數(shù)據(jù)到es(一、es模板問題,請(qǐng)求返回400) logstash同步mysql數(shù)據(jù)到es(二、jdbc_driver_library問題)_(please check user and group permissions for the p-CSDN博客 logstash同步mysql數(shù)據(jù)到es(三、es模板問題)-CSDN博客 使用docker實(shí)現(xiàn)logstash同步mysql到es-CSDN博客 [INFO ] 2023-12-11 09

    2024年01月17日
    瀏覽(19)
  • ELK增量同步數(shù)據(jù)【MySql->ES】

    ELK增量同步數(shù)據(jù)【MySql->ES】

    ? ? ? ? 1.? linux,已經(jīng)搭建好的logstash+es+kibana【系列版本7.0X】,es 的plugs中安裝ik分詞器 ES版本: ?Logstash版本: ?(以上部署,都是運(yùn)維同事搞的,我不會(huì)部署,同事給力) 1、在Logstash安裝目錄下【/usr/share/logstash】,新建XX.sh,內(nèi)容如下: 2. 在Logstash安裝目錄下【/usr/shar

    2024年02月11日
    瀏覽(21)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包