Giter Club home page Giter Club logo

lcvsearch's Introduction

基于 ElasticSearch 的新闻、研报、互动易搜索引擎

1、使用 ElasticSearch 5.1.1 中文发行版,针对中文集成了相关插件,方便学习测试.

2、ElasticSearch-head

3、kibana-5.1.1


添加热搜关键词、热词统计并取出前5个

 import redis
 redis_cli = redis.StrictRedis()
 keywords = "关键词"
 # 搜索关键词+1操作
 redis_cli.zincrby("search_keywords_set", 1, keywords)
  # 统计热词Top5
 top_n_search = redis_cli.zrevrangebyscore("search_keywords_set", "+inf", "-inf", start=0, num=5)

es的文档、索引的CRUD操作

新建分片、副本数量
PUT article
{
    "settings": {
        "index": {
            "number_of_shards": 5,
            "number_of_replicas": 1
        }
    }
}

查看设置
GET article/_settings
GET .all/-settings
GET _settings

修改设置
PUT article/_settings
{
    "number_of_replicas": 2
}

查看索引信息
GET all
GET article

新增文档
POST article/cls
{
    "title": "新闻标题",
    "salary_min": 15000,
    "company": {
        "stock_name": "万科A",
        "stock_code": "000002"
    },
    "publish_time": "发布日期",
    "content": "新闻内容"
}

POST article/cls/1
{
    "title": "新闻标题",
    "salary_min": 18000,
    "company": {
        "stock_name": "平安银行",
        "stock_code": "000001"
    },
    "publish_time": "发布日期",
    "content": "新闻内容"
}

查看文档
GET article/cls/1
GET article/cls/1?_source
GET article/cls/1?_source=title
GET article/cls/1?_source=title, content

修改文档(覆盖式)
PUT article/cls/1
{
    "title": "新闻标题",
    "salary_min": 18000,
    "company": {
        "stock_name": "平安银行",
        "stock_code": "000001"
    },
    "publish_time": "发布日期",
    "content": "新闻内容"
}

指定修改
POST article/cls/1/_update
{
    "doc": {
        content: "内容......"
    }
}

删除文档,类(无法删除),索引
DELETE article/cls/1
DELETE article/cls
DELETE article

es的mget和bulk批量操作

mget操作实例
GET _mget
{
    "docs": [
        {
            "_index": "test_db"
            "_type": "job1",
            "_id": 1
        },
        {
             "_index": "test_db"
            "_type": "job1",
            "_id": 2
        }
    ]
}
GET test_db/_mget
{
    "docs": [
        {
            "_type": "article1",
            "_id": 1
        },
        {
        "_type": "article1",
        "_id": 2
        }
    ]
}
GET test_db/article1/_mget
{
    "docs": [
        {
            "_id": 1
        },
        {
        "_id": 2
        }
    ]
}
GET test_db/job1/_mget
{
    "ids": [1, 2]
}

lcvsearch's People

Contributors

hhs0503 avatar huanglaoxie0503 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.