es可以把mysql里的字符串解析出来搜索吗?

例如:mysql一个字段的是一大串内容,想做like %%这些查询很慢,所以想能不能把这一大串解析出来放到es里,然后提供检索。
谢谢了

阅读 2.1k
2 个回答

可以用Logstash jdbc 插件向es里面导入数据,配置大概长这样,然后 bin/logstash -f configFileName开始同步

input {

  jdbc {
             jdbc_driver_library=>"mysql-connector-java-8.0.12.jar"
             jdbc_driver_class => "com.mysql.jdbc.Driver"
             jdbc_connection_string => "jdbc:mysql://localhost:3306/dbname"
             jdbc_user => "user"
             jdbc_password => "passwd"
             statement  => "select xxx from xxx"
             schedule => " * * * * * "
             tracking_column=>"xxx"
             tracking_column_type =>"numeric"
             use_column_value=>true
             record_last_run=>true
             last_run_metadata_path => "xxx.txt"
             jdbc_paging_enabled => true
   }
}

output {
    stdout {
        codec => json_lines
    }
   
    elasticsearch {
        hosts => ["http://localhost:9200"]
        index => "indexName"
        document_id => "%{id}"
    }
}

写一个脚本向 es 中同步 mysql 上的数据?

ps:我不是很明白你的意思。。不知道是不是这个意思

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进