配置文件

2018-11-12  本文已影响0人  dotff

一. solr配置

1. data-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<dataConfig>
    <dataSource name="source1" type="JdbcDataSource" driver="com.mysql.jdbc.Driver"
        url="jdbc:mysql://localhost:3306/redseft" user="root" password="521" batchSize="-1" />
    <document>
        <entity name="game" pk="gameId" dataSource="source1" query="select *,'GAME' as type from game where del_flag ='0'"
            deltaImportQuery="select *,'GAME' as type from game where id='${dih.delta.gameId}'"
            deltaQuery="SELECT id as gameId FROM game where create_time &gt; '${dih.last_index_time}'">
            
            
            <field column="id" name="gameId" />
            <field column="title" name="title" />
            <field column="status" name="status" />
            <field column="area_code" name="area_code" />
            <field column="max_people" name="max_people" />
            <field column="pass" name="pass" />
            <field column="apply_start_time" name="apply_start_time" />
            <field column="apply_end_time" name="apply_end_time" />
            <field column="game_start_time" name="game_start_time" />
            <field column="game_end_time" name="game_end_time" />
            <field column="description" name="description" />
            <field column="items" name="items" />
            <field column="is_insurance" name="is_insurance" />
            <field column="insurance_link" name="insurance_link" />
            <field column="sex_limit" name="sex_limit" />
            <field column="location" name="location" />
            <field column="preview_img" name="preview_img" />
            <field column="show_img" name="show_img" />
            <field column="create_time" name="create_time" dateTimeFormat="yyyy-MM-dd HH:mm" />
            <field column="hot_no" name="hot_no" />
            <field column="type" name="type" />
            <field column="update_time" name="type" />
        </entity>

        <entity name="news" pk="newsId" dataSource="source1" query="select *,'NEWS' as type from news where del_flag ='0'"
            deltaImportQuery="select *,'NEWS' as type from news where id='${dih.delta.newsId}'"
            deltaQuery="SELECT id as newsId FROM news where create_time &gt; '${dih.last_index_time}'">
            
            <field column="id" name="newsId" />
            <field column="tags" name="tags" />
            <field column="title" name="title" />
            <field column="summary" name="summary" />
            <field column="show_img" name="show_img" />
            <field column="type" name="type" />
            <field column="create_time" name="create_time" dateTimeFormat="yyyy-MM-dd HH:mm" />
        </entity>

    </document>
</dataConfig>    

2. schema
<!-- ik分词器 -->
    <fieldType name="text_ik" class="solr.TextField">
        <analyzer type="index">
            <tokenizer class="org.wltea.analyzer.lucene.IKTokenizerFactory" useSmart="false" conf="ik.conf"/>
             <filter class="solr.LowerCaseFilterFactory"/>
        </analyzer>
        <analyzer type="query">
            <tokenizer class="org.wltea.analyzer.lucene.IKTokenizerFactory" useSmart="true" conf="ik.conf"/>
             <filter class="solr.LowerCaseFilterFactory"/>
        </analyzer>
    </fieldType>



     <field name="gameId" type="string" indexed="true" stored="true" />
     <field name="title" type="text_ik" indexed="true" stored="true"  />
     <field name="status" type="string" indexed="true" stored="true" />
     <field name="area_code" type="string" indexed="true" stored="true" />
     <!-- <field name="max_people" type="int" indexed="true" stored="true" /> -->
     <!-- <field name="pass" type="int" indexed="true" stored="true" /> -->
     <!-- <field name="apply_start_time" type="date" indexed="true" stored="true" />
     <field name="apply_end_time" type="string" indexed="true" stored="true" />
     <field name="game_start_time" type="string" indexed="true" stored="true" />
     <field name="game_end_time" type="string" indexed="true" stored="true" /> -->
     <field name="description" type="text_ik" indexed="true" stored="true"  />
     <field name="items" type="string" indexed="true" stored="true" />
     <field name="location" type="string" indexed="true" stored="true" />
     <field name="show_img" type="string" indexed="true" stored="true" />
     <field name="create_time" type="string" indexed="true" stored="true" />
     <!-- <field name="hot_no" type="int" indexed="true" stored="true" /> -->
    <field name="newsId" type="string" indexed="true" stored="true" />
    <field name="tags" type="text_ik" indexed="true" stored="true" />
    <field name="summary" type="text_ik" indexed="true" stored="true" />

    <field name="type" type="string" indexed="true" stored="true" />
    <field name="showSearch" type="text_ik" indexed="true" stored="true" multiValued="true" />

    

     <copyField source="tags" dest="showSearch"/>
     <copyField source="title" dest="showSearch"/>
     <copyField source="description" dest="showSearch"/>
     <copyField source="summary" dest="showSearch"/>

二. nginx配置

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    gzip  on;
    gzip_comp_level  5;
    gzip_min_length  1024;
    gzip_types   text/plain application/x-javascript text/css application/xml text/javascript  image/jpeg image/gif image/png;
    server {
        # 默认电脑端访问
        listen       80;
        server_name  ff.com www.ff.com;   #localhost;
        #access_log  logs/host.access.log  main;
        location / {
            root   /usr/local/project/static/pc;
            index  index.html ;
        }
        # 根据header判断是否是手机端用户  如果是手机端端就跳转m站
        if ( $http_user_agent ~* "(Android|iPhone|Windows Phone|UC|Kindle)" ){
            rewrite ^/(.*)$  http://m.ff.com$uri redirect;
        }
    }
    # 手机端访问m站
    server {
        listen       80;
        server_name  m.ff.com;
        location / {
            root   /usr/local/project/static/phone;
            # try_files $uri $uri/ /index.html last;
            index  index.html;
        }
    }
    # 后端接口 二级域名 跳转到 springboot占用的8888端口
    server {
        listen       80;
        server_name  api.ff.com;
        location / {
            proxy_pass   http://localhost:8888;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $http_host;
        }
    }

    # 后台管理系统
    server {
        listen       8800;
        server_name  localhost;
        location / {
            root   /usr/local/project/static/admin;
            try_files $uri $uri/ /index.html last;
            index  index.html;
        }
    }


}

一. elasticsearch配置

从数据库获取父子结构的数据

  1. 配置es
network.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"
http.port: 9200
transport.tcp.port: 9300
transport.tcp.compress: true
  1. 配置logstash
input {
    jdbc {
      jdbc_connection_string => "jdbc:mysql://45.96.132.27:3306/bat_test?zeroDateTimeBehavior=convertToNull"
      jdbc_user => "root"
      jdbc_password => "ahahaha2"
      jdbc_driver_library => "../config/mysql-connector-java-5.1.41.jar"
      jdbc_driver_class => "com.mysql.jdbc.Driver"
      jdbc_paging_enabled => "true"
      jdbc_page_size => "50000"
      statement_filepath => "../config/getOrder.sql"
      schedule => "*/5 * * * *"
      type => "jdbc_order"
      add_field => { "join_field" => "order"}
      
    }
    jdbc {
      jdbc_connection_string => "jdbc:mysql://45.96.132.27:3306/bat_test?zeroDateTimeBehavior=convertToNull"
      jdbc_user => "root"
      jdbc_password => "ahahaha2"
      jdbc_driver_library => "../config/mysql-connector-java-5.1.41.jar"
      jdbc_driver_class => "com.mysql.jdbc.Driver"
      jdbc_paging_enabled => "true"
      jdbc_page_size => "50000"
      statement_filepath => "../config/getProduct.sql"
      schedule => "*/5 * * * *"
      type => "jdbc_product"
      add_field => {
                "[join_field][name]" => "product"
                "[join_field][parent]" => "%{order_id}"
            }
    }
    
}
output {
 stdout {
        codec => json_lines
    }
    if[type] == "jdbc_order"{
        elasticsearch {
        hosts  => "localhost:9200"
        index => "order_product_index"
        document_type => "order"
        document_id => "%{order_id}"
        }
    }
    if[type] == "jdbc_product"{
        elasticsearch {
        hosts  => "localhost:9200"
        index => "order_product_index"
        document_type => "order"
        document_id => "%{id}"
        routing => "%{order_id}"
        }
    }
}
  1. 创建索引
put  localhost:9200/order_product_index/ 
{
 "mappings": {
   "order": {
     "properties": {
       "join_field": { 
         "type": "join",
         "relations": {
           "order": "product" 
         }
       }
     }
   }
 }
}
  1. 搜索:查询父文档,并显示所有子文档
get localhost:9200/order_product_index/order/_search
{
    "query": {
        "has_child": {
            "type": "product",
            "query": {
                "match_all": {}
            },
            "inner_hits": {}
        }
    }
}
  1. 搜索:根据父文档查询,并显示所有子文档
{
    "query": {
        "bool": {
            "filter": 
             
                {
                    "bool":{
                        "should":[
                            {
                                "regexp": { "creatorname": ".*冯帆海涛.*"}
                            },
                            {
                                "regexp": { "order_id": ".*100000156.*"}
                            }
                        ]
                
                    }
                }
            ,
            "must":[
                {
                    "has_child": {
                        "type": "product",
                        "query": {
                            "match_all": {}
                        },
                        "inner_hits": {"size": 10}
                    }
                }
            ]
        }
        
        
        
    },
    "from" : 0,
    "size" : 10,
    "sort":{"create_time":{"order":"desc"}}
}
上一篇 下一篇

猜你喜欢

热点阅读