zoukankan      html  css  js  c++  java
  • ElasticSearch

    mongoid-elasticsearch

    https://github.com/rs-pro/mongoid-elasticsearch

    gem 'mongoid-elasticsearch'
    $ bundle

    class Post
      include Mongoid::Document
      include Mongoid::Elasticsearch
      elasticsearch!
    end

    Post.es.search 'test text' # shortcut for Post.es.search({q: 'test text'})
    result = Post.es.search body: {query: {...}, facets: {...}} etc
    result.raw_response
    result.results # by default returns an Enumerable with Post instances exactly
                   # like they were loaded from MongoDB
    Post.es.index.create(Post.es.index_all) # create index (done automatically on app boot)
    Post.es.index.destroy(Post.es.index.delete) # drop index
    Post.es.index.reset # recreate index
    Post.es.index.refresh # force index update (useful for specs)
    Post.es.client # Elasticsearch::Client instance

    response = Mongoid::Elasticsearch.search 'test'

    Reindexing

    All models

    rake es:reindex will reindex all indices managed by Mongoid::Elasticsearch

    One model - Simple bulk

    This is the preferred (fastest) method to reindex everything

    Music::Video.es.index_all
    

    One model - Simple

    Communities::Thread.es.index.reset
    Communities::Thread.enabled.each do |ingr|
      ingr.es_update
    end
    
     

    自定义elasticsearch! : http://stackoverflow.com/questions/21430601/sorting-search-results-with-mongoid-elasticsearch-gem

    ElasticSearch搜索: http://www.qwolf.com/?p=1387

  • 相关阅读:
    WP2Sinablog使用后的后遗症
    .NET Framework 4 与 .NET Framework 4 Client Profile
    360浏览器也有了开发人员工具了
    让你的手机号“变”qq号
    首次体验 Live Writter
    判断素数
    SqlServer文件挂起
    vni—2015:验证错误
    成功者善于模仿(转)
    dbms_output缓冲区溢出
  • 原文地址:https://www.cnblogs.com/qinyan20/p/3858644.html
Copyright © 2011-2022 走看看