-
倒排索引規則
查看全部 -
同步方法,es官方提供的logstash
命令: logstash -f ../config/mysql.conf
mysql.conf:
input {
? jdbc {jdbc_driver_library => "E:\\es\logstash-6.5.2\\mysql-connector-java-5.1.43.jar"
??? jdbc_driver_class => "com.mysql.jdbc.Driver"
??? jdbc_connection_string => "jdbc:mysql://localhost:3306/mp"
??? jdbc_user => "root"
??? jdbc_password => "ROOT"
??? schedule => "* * * * *"
??? clean_run => true
??? statement => "select * from tb_blog? where create_time > :sql_last_value and create_time < NOW() order by create_time desc"
? }
}
output {
? elasticsearch {
??? hosts => ["http://localhost:9200"]
??? index => "blog"
??? document_id => "%{id}"
? }
}查看全部 -
springboot解決前端跨域問題配置
查看全部 -
通過es條件查詢封裝過程
查看全部 -
新增數據-person
{"first_name" : "John",
"last_name" : "Smith",
"age" : 25,
"about" : "Hello world",
"interests" :["music","Sports"]}
查看全部 -
spring自帶的耗時統計,StopWatch?watch =?new StopWatch();
watch.start();
watch.stop();
long time = watch.getTotalTimeMillis();
查看全部 -
ES的dao接口
查看全部 -
使用線上的es配置,createIndex=false就是啟動springboot時候不去創建index,避免刪除線上的index
查看全部 -
springboot里引入lombok依賴(新建項目時就可選擇),可在實體類上配置@Data,就能省略get,set方法編寫,這里還差個@Entity配置
查看全部 -
es分詞器類型:(可下載第三方插件分詞器,有對中文更好的支持)
查看全部 -
mysql和es數據同步,es官方提供的logstash
遷移命令: logstash -f ../config/mysql.conf
配置內容:
input {
? jdbc {
? ? jdbc_driver_library => "D:\\es\logstash-7.6.2\\mysql-connector-java-5.1.37-bin.jar"
? ? jdbc_driver_class => "com.mysql.jdbc.Driver"
? ? jdbc_connection_string => "jdbc:mysql://192.168.0.132:3306/estest"
? ? jdbc_user => "root"
? ? jdbc_password => "root"
? ? schedule => "* * * * *"
? ? clean_run => true
? ? statement => "select * from user where createtime > :sql_last_value and createtime < NOW() order by createtime desc"
? }
}
output {
? elasticsearch {
? ? hosts => ["http://localhost:9200"]
? ? index => "user"
? ? document_id => "%{code}"
? }
}
查看全部 -
剛好在數據同步的時候,mysql有新的數據插入,可采用createtime時間,每次增量同步上次時間到現在最新時間段內的數據
查看全部 -
ES在存入數據的時候,就會對數據進行分詞,對查詢搜索效率提升
查看全部 -
ES條件查詢(可省略_doc),should里可有多個match,相當于or語句,should改成must,就變成了and語句
POST /person/_search
{
? "query": {
? ? "bool": {
? ? ? "should": [
? ? ? ? {
? ? ? ? ? "match": {
? ? ? ? ? ? "last_name": "Simth"
? ? ? ? ? }
? ? ? ? },
? ? ? ? {
? ? ? ? ? "match": {
? ? ? ? ? ? "about": "love"
? ? ? ? ? }
? ? ? ? }
? ? ? ]
? ? }
? }
}
查看全部 -
es根據主鍵查詢:GET /person/_doc/1
查看全部
舉報