资源简介

利用mongodb、django、elasticsearch等搭建的小型搜索引擎。数据由scrapy框架爬取存入mongodb中,具体使用方法请移步我的github:https://github.com/Weifanwong/search_engine.git

资源截图

代码片段和文件信息

from datetime import datetime
from elasticsearch_dsl import DocType Date Nested Booleananalyzer Completion Keyword Text Integer

from elasticsearch_dsl.connections import connections
from elasticsearch_dsl.analysis import CustomAnalyzer

connections.create_connection(hosts=[‘127.0.0.1‘])

class Analyzer(CustomAnalyzer):
    def get_analysis_definition(self):
        return {}

ik_analyzer = Analyzer(‘ik_max_word‘ filter=[‘lowercase‘])


class ShuimuType(DocType):  # 
    title = Text(analyzer=“ik_max_word“)
    content = Text(analyzer=“ik_max_word“)
    article_id = Keyword()
    origin_url = Keyword()
    avatar = Keyword()
    author = Keyword()
    pub_time = Date()
    read_count = Integer()
    like_count = Integer()
    word_count = Integer()
    subjects = Text(analyzer=“ik_max_word“)
    comment_count = Integer()


    class Index:
        name = ‘my-index‘
        # doc_type = ‘jianshu‘
        # index = “scrapy“


if __name__ == “__main__“:
    ShuimuType.init()

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-02-19 10:43  qsinghua\
     文件        6148  2018-12-16 19:26  qsinghua\.DS_Store
     目录           0  2019-02-20 15:20  qsinghua\.git\
     文件          66  2018-12-20 10:59  qsinghua\.gitattributes
     文件          17  2019-02-20 15:20  qsinghua\.git\COMMIT_EDITMSG
     文件         305  2018-12-20 11:00  qsinghua\.git\config
     文件          37  2018-12-20 10:59  qsinghua\.git\description
     文件         100  2019-02-20 15:10  qsinghua\.git\FETCH_HEAD
     文件          23  2018-12-20 10:59  qsinghua\.git\HEAD
     目录           0  2018-12-23 11:11  qsinghua\.git\hooks\
     文件         478  2018-12-20 10:59  qsinghua\.git\hooks\applypatch-msg.sample
     文件         896  2018-12-20 10:59  qsinghua\.git\hooks\commit-msg.sample
     文件        3327  2018-12-20 10:59  qsinghua\.git\hooks\fsmonitor-watchman.sample
     文件         189  2018-12-20 10:59  qsinghua\.git\hooks\post-update.sample
     文件         424  2018-12-20 10:59  qsinghua\.git\hooks\pre-applypatch.sample
     文件        1638  2018-12-20 10:59  qsinghua\.git\hooks\pre-commit.sample
     文件        1348  2018-12-20 10:59  qsinghua\.git\hooks\pre-push.sample
     文件        4898  2018-12-20 10:59  qsinghua\.git\hooks\pre-rebase.sample
     文件         544  2018-12-20 10:59  qsinghua\.git\hooks\pre-receive.sample
     文件        1492  2018-12-20 10:59  qsinghua\.git\hooks\prepare-commit-msg.sample
     文件        3610  2018-12-20 10:59  qsinghua\.git\hooks\update.sample
     文件        6108  2019-02-20 15:20  qsinghua\.git\index
     目录           0  2018-12-23 11:11  qsinghua\.git\info\
     文件         240  2018-12-20 10:59  qsinghua\.git\info\exclude
     目录           0  2018-12-23 11:11  qsinghua\.git\logs\
     文件        1093  2019-02-20 15:20  qsinghua\.git\logs\HEAD
     目录           0  2018-12-23 11:11  qsinghua\.git\logs\refs\
     目录           0  2018-12-23 11:11  qsinghua\.git\logs\refs\heads\
     文件        1093  2019-02-20 15:20  qsinghua\.git\logs\refs\heads\master
     目录           0  2018-12-23 11:11  qsinghua\.git\logs\refs\remotes\
     目录           0  2018-12-23 11:11  qsinghua\.git\logs\refs\remotes\origin\
............此处省略268个文件信息

评论

共有 条评论