GithubHelp home page GithubHelp logo

isabella232 / twitter-search Goto Github PK

View Code? Open in Web Editor NEW

This project forked from algolia/twitter-search

0.0 0.0 0.0 484 KB

Twitter Handles search like you expected it to be.

Home Page: http://twittersearch.algolia.io

Ruby 71.96% JavaScript 13.92% CSS 14.11%

twitter-search's Introduction

Twitter Search powered by Algolia

This is the Rails 4 application providing Twitter Search. It's based on algoliasearch-rails and uses Twitter's Streaming API to crawl new users.

Configuration

class Handle < ActiveRecord::Base
  include AlgoliaSearch

  algoliasearch per_environment: true do
    # add an extra score attribute
    add_attribute :score

    # add an extra full_name attribute: screen_name + name
    add_attribute :full_name

    # do not take `full_name`'s words order into account, `full_name` is more important than `description`
    attributesToIndex ['unordered(full_name)', :description]

    # list of attributes to highlight
    attributesToHighlight [:screen_name, :name, :description]

    # use followers_count OR mentions_count to sort results (last sort criteria)
    customRanking ['desc(score)']

    # @I_love_you
    separatorsToIndex '_'

    # tag top-users
    tags do
      followers_count > 10000000 ? ['top'] : []
    end
  end

  def full_name
    "#{screen_name} #{name}"
  end

  # the custom score
  def score
    return followers_count if followers_count > 0
    if mentions_count < 10
      mentions_count
    elsif mentions_count < 100
      mentions_count * 10
    elsif mentions_count < 1000
      mentions_count * 100
    else
      mentions_count * 1000
    end
  end

end

Setup

Installation

An Algolia account is required to test it.

  • git clone https://github.com/algolia/twitter-search.git
  • bundle install
  • Setup your config/database.yml
  • bundle exec rake db:migrate

Start crawling

  • Create your config/application.yml based on config/application.example.yml with your Algolia and Twitter credentials
  • Run ./bin/crawler run to start a foreground crawler
  • And periodically run rails runner Handle.reindex! to index crawled Handles

Start the application

  • bundle exec rails server
  • Enjoy your http://localhost:3000 Twitter Handles search!

twitter-search's People

Contributors

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