• mynote es elasticsearch
  • mynote es/kibana 部署
  • 排错
  • 参数传递
  • note 注意
  • es commits
  • 索引管理
  • all in postman --
  • create mapping
  • es 查询
  • 全文搜索 normal
  • 实际使用的查询
  • mynote es elasticsearch
    elasticsearch es sum 
    kibana 
    es-php-client http://uninote.com.cn/book/1021/1434
    params.php:
    'es_host' => '127.0.0.1',
    'es_port' => '9200',
    'es_index' => 'mynote',
    \app\controllers\api\ArticleController::actionSearch
    \app\controllers\SearchController::actionIndex
     \app\models\api\Search::index
    增删改查核心
    E:\uninote\mynote\basic\models\ESBase.php
    E:\uninote\mynote\basic\models\elasticSearch\Article.php extends ESBase

    mynote es/kibana 部署

    es 部署文档 
    目前是 centos6 部署的,没有用 docker hub。
    docker start 通过 /entrypoint.sh 启动 es,但没有启动 kibana(节约内存)

    排错

    搜索结果不正常,简单的重启 es,重新索引即可索引管理 

    参数传递

    vendor\elasticsearch\elasticsearch\src\Elasticsearch\Connections\Connection.php
    {
        "index": "mynotev23",
        "type": "article",
        "body": {param}
    }
    =>
    GET /mynotev23/article/_search
    {param}
    public function customSearch($param)
    {
        $contents = [
            'index' => $this->index,
            'type' => 'article',
            'body' => $param
        ];

    note 注意

    搜索时,既要从数据库搜索tag等,又要从es搜索文章;同时文章的的阅读量等信息也要从数据库中获取

    es commits

    SHA-1: 2e2145fd7b10e856b012b0a8a051bb7ec6df3a94
    * search: 完成文章搜索
    lv1= lv2= type=

    索引管理

    访问此链接,建立文章索引
    http://uninote.com.cn/api/synes
    删除index:
    DELETE /mynote
    清空es:
    POST http://[域名]:9200/[es数据库名称]/article/_delete_by_query?refresh&slices=5&pretty 发送 
    {
      "query": {
        "match_all": {}
      }
    }

    all in postman --

    依次执行:

    create mapping

    http://uninote.com.cn/book/1011/1116
    PUT /mynote
    。。。
    E:\uninote\mynote\es_mapping

    es 查询

    全文搜索 normal

    GET /mynote/article/_search
    {
      
      "query": {
        "match": {
          "content": "创建完成"
        }
      }
    }

    实际使用的查询

    GET /mynote/article/_search
    {
                "query": {
                    "dis_max": {
                        "tie_breaker": 0.7,
                        "boost": 1.2,
                        "queries": [
                            {
                                "bool": {
                                    "should": [
                                        {
                                            "multi_match": {
                                                "query": "日志",
                                                "fields": ["content", "content.pinyin", "username", "username.pinyin", "title","title.pinyin"],
                                                "analyzer":"ik_max_word"
                                            }
                                        },
                                        {
                                            "term": {
                                                "tag": {
                                                    "value": "123"
                                                }
                                            }
                                        }
                                    ]
                                }
                            }
                        ]
                    }
                },
                "highlight": {
                    "fields": [
                        {"tag" :{}},
                        {"title" :{}},
                        {"content" :{}},
                        {"username" :{}},
                        {"title.pinyin" :{}},
                        {"content.pinyin" :{}},
                        {"username.pinyin" :{}}
                    ]
                },
                "size": 10,
                "from": 0,
                "_source":[
                    "highlight", "title", "article_id", "title", "abstract", "thum", "id"
                ]
            }