<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                - 安裝elasticsearch模塊 - 進入python交互界面 - 引入es的模塊 ``` from elasticsearch import Elasticsearch ``` - 定義es鏈接及變量 ``` doc_type = 'log' es = Elasticsearch(urls = ['http://192.168.1.108:9200','http://192.168.1.106:9200'], timeout = 60, max_retries = 0) ``` - 設置mapping - 創建索引 ``` es.index(index = 'app-log', doc_type='log', body = mapping) ``` ``` mapping = { 'settings': { 'index': { 'number_of_replicas': 1, 'number_of_shards': 6, 'refresh_interval': '5s' } }, 'mappings': { '_default_': { '_all': { 'enabled': False } }, doc_type : { 'properties' : { 'day': { 'type': 'string', 'index': 'not_analyzed'}, 'time': { 'type': 'string', 'index': 'not_analyzed'}, 'nanoTime': { 'type': 'string', 'index': 'not_analyzed'}, 'created': { 'type': 'date', 'index': 'not_analyzed'}, 'app': { 'type': 'string', 'index': 'not_analyzed'}, 'host': { 'type': 'string', 'index': 'not_analyzed'}, 'thread': { 'type': 'string', 'index': 'not_analyzed'}, 'level': { 'type': 'string', 'index': 'not_analyzed'}, 'eventType': { 'type': 'string', 'index': 'not_analyzed'}, 'pack': { 'type': 'string', 'index': 'not_analyzed'}, 'clazz': { 'type': 'string', 'index': 'not_analyzed'}, 'line': { 'type': 'string', 'index': 'not_analyzed'}, 'messageSmart': { 'type': 'text', 'analyzer': 'ik_smart', 'search_analyzer': 'ik_smart', 'include_in_all': 'true', 'boost': 8}, 'messageMax': { 'type': 'text', 'analyzer': 'ik_max_word', 'search_analyzer': 'ik_max_word', 'include_in_all': 'true', 'boost': 8} } } } } ``` ### 驗證 ``` curl '192.168.1.108:9200/_cat/indices?v' ``` ### 完整腳本 ```python #!/usr/bin/python # -*- coding: UTF-8 -*- import sys import datetime from pyelasticsearch import ElasticSearch from pyelasticsearch import bulk_chunks def main(argv): doc_type = 'log' index = 'app-log' es = ElasticSearch(urls = ['http://192.168.1.108:9200'], timeout = 60, max_retries = 0) mapping = { 'settings': { 'index': { 'number_of_replicas': 1, 'number_of_shards': 6, 'refresh_interval': '5s' } }, 'mappings': { '_default_': { '_all': { 'enabled': False } }, doc_type : { 'properties' : { 'day': { 'type': 'string', 'index': 'not_analyzed'}, 'time': { 'type': 'string', 'index': 'not_analyzed'}, 'nanoTime': { 'type': 'string', 'index': 'not_analyzed'}, 'created': { 'type': 'date', 'index': 'not_analyzed'}, 'app': { 'type': 'string', 'index': 'not_analyzed'}, 'host': { 'type': 'string', 'index': 'not_analyzed'}, 'thread': { 'type': 'string', 'index': 'not_analyzed'}, 'level': { 'type': 'string', 'index': 'not_analyzed'}, 'eventType': { 'type': 'string', 'index': 'not_analyzed'}, 'pack': { 'type': 'string', 'index': 'not_analyzed'}, 'clazz': { 'type': 'string', 'index': 'not_analyzed'}, 'line': { 'type': 'string', 'index': 'not_analyzed'} # 'messageSmart': { 'type': 'string', 'analyzer': 'ik_smart', 'search_analyzer': 'ik_smart', 'include_in_all': 'true', 'boost': 8}, } } } } es.create_index(index = index, settings = mapping) if __name__ == '__main__': main(sys.argv) ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看