Giter Site home page Giter Site logo

mongodb_elasticsearch_jieba's Introduction

mongodb_elasticsearch_jieba

ubuntu 14.04 使用elasticsearch+jieba+ mongodb 搜索

1.安装elasticsearch(注意elasticsearch的版本)

参考链接 :https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-elasticsearch-on-ubuntu-14-04 http://www.vpsee.com/2014/05/install-and-play-with-elasticsearch/ 版本选为2.3.4 ''' Download and install the Public Signing Key:

wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - Save the repository definition to /etc/apt/sources.list.d/elasticsearch-2.x.list:

echo "deb https://packages.elastic.co/elasticsearch/2.3/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.3.list Warning Use the echo method described above to add the Elasticsearch repository. Do not use add-apt-repository as it will add a deb-src entry as well, but we do not provide a source package. If you have added the deb-src entry, you will see an error like the following:

Unable to find expected entry 'main/source/Sources' in Release file (Wrong sources.list entry or malformed file) Just delete the deb-src entry from the /etc/apt/sources.list file and the installation should work as expected.

Run apt-get update and the repository is ready for use. You can install it with:

sudo apt-get update && sudo apt-get install elasticsearch ''' 2.jieba分词插件 https://github.com/huaban/elasticsearch-analysis-jieba

3.mongodb开启副本集 本机mongodb已经装好了(port 27017) 目录在\www\data

  1. 停止mongodb service mongodb stop
  2. 开启副本集 mongod --port 27017 --dbpath "\www\data" --replSet rs0
  3. 重新开一个终端 输入mongo 进入mongodb shell,输入 rs.initiate() 来初始化 副本集

4.利用mongo-connector 来同步Mongo内的数据到 elasticsearch

  1. pip install mongo-connector
  2. mongo-connector -m localhost:27017 -t localhost:9200 -d elastic2_doc_manager 同步~

5.搜索https://github.com/elastic/elasticsearch-py

https://elasticsearch-py.readthedocs.io/en/master/api.html#elasticsearch.Elasticsearch.search http://es.xiaoleilu.com/

  1. pip install elasticsearch
  2. 查询

from elasticsearch import Elasticsearch es = Elasticsearch() all = es.search(index='douban',doc_type='xxx',body=body,from_=0,size=10) 这里是显示第一页的结果 *第二页则是from=10,size=10 *第三页则是from=20,size=10 http://www.one-tab.com/page/rZmjjQafRu2s3NZoy6ZwlA }

6.注意事项

  1. make sure that action.auto_create_index is set to true in your elasticsearch.yml
  2. Installing mongo-connector as a Linux Service
  3. 实在不行就按照这个全部重新配置一次

mongodb_elasticsearch_jieba's People

Contributors

jin10086 avatar

Watchers

 avatar  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.