Giter VIP home page Giter VIP logo

omnisearch-rails's Introduction

omnisearch-rails

A simple rails api application that provides search results from google and/or bing

API endpoints

GET /search

Parameters

Name Required Type Description
engine required string Search engine(s) to be used.

Supported values: google, bing, both.
text required string Search query.

Sample request

http://localhost:3000/search?engine=both&text=elshaka

Response

{
  "query": "elshaka",
  "status": "ok",
  "status_by_provider": [
    {
      "provider": "google",
      "status": "ok",
      "error_messages": null
    },
    {
      "provider": "bing",
      "status": "ok",
      "error_messages": null
    }
  ],
  "results": [
    {
      "provider": "google",
      "title": "elshaka (Eleazar Meza) · GitHub",
      "link": "https://github.com/elshaka"
    },
    {
      "provider": "bing",
      "title": "El shaka: qué significa la señal y dónde se originó",
      "link": "https://www.elnacional.com/gda/el-shaka-que-significa-la-senal-y-donde-se-origino/"
    },
    {
      "provider": "google",
      "title": "Mn Kebd Kebd Elshaka by Maged Elkedwany on Amazon Music ...",
      "link": "https://www.amazon.com/Mn-Kebd-Elshaka-Maged-Elkedwany/dp/B085R8H58G"
    },
    {
      "provider": "bing",
      "title": "Sergio Vega \"El Shaka\" - Quién Es Usted - YouTube",
      "link": "https://www.youtube.com/watch?v=s3_tYVxnOCE"
    },
    {
      "provider": "google",
      "title": "Mexican singer El Shaka killed after denying his murder - BBC News",
      "link": "https://www.bbc.com/news/10429934"
    },
    {
      "provider": "bing",
      "title": "El shaka: qué significa esta señal y dónde se originó",
      "link": "https://www.eluniversal.com.mx/destinos/el-shaka-que-significa-esta-senal-y-donde-se-origino"
    },
    {
      "provider": "google",
      "title": "Sergio Vega (singer) - Wikipedia",
      "link": "https://en.wikipedia.org/wiki/Sergio_Vega_(singer)"
    },
    {
      "provider": "bing",
      "title": "El Shaka (letra y canción) - El Halcon de la sierra ...",
      "link": "https://www.musica.com/letras.asp?letra=1093055"
    },
    {
      "provider": "google",
      "title": "Ahmed Elshaka (@ahmedelshaka) • Instagram photos and videos",
      "link": "https://www.instagram.com/ahmedelshaka/"
    },
    {
      "provider": "bing",
      "title": "Un saludo surfero: El Shaka | Surfeando un charco",
      "link": "https://surfeandouncharco.com/saludo-surfero/"
    },
    {
      "provider": "google",
      "title": "Emara fi elshaka Fi eloda 123 no | Grammar Quiz - Quizizz",
      "link": "https://quizizz.com/admin/quiz/5c7536ac613075001a2be023/emara-fi-elshaka-fi-eloda-123-no"
    },
    {
      "provider": "bing",
      "title": "Sergio Vega - Wikipedia, la enciclopedia libre",
      "link": "https://es.wikipedia.org/wiki/Sergio_Vega"
    },
    {
      "provider": "google",
      "title": "Elshaka Rivera | Facebook",
      "link": "https://www.facebook.com/elshaka.rivera.1"
    },
    {
      "provider": "bing",
      "title": "El Shaka (2012) Online - Película Completa en Español ...",
      "link": "https://www.fulltv.com.ar/peliculas/el-shaka-2012.html"
    },
    {
      "provider": "google",
      "title": "The Violent Death of Sergio 'El Shaka' Vega, Drug Balladeer - WSJ",
      "link": "https://www.wsj.com/articles/BL-SEB-39394"
    },
    {
      "provider": "bing",
      "title": "Shaka - Wikipedia, la enciclopedia libre",
      "link": "https://es.wikipedia.org/wiki/Shaka"
    },
    {
      "provider": "google",
      "title": "Bank Alrahaman Awad Elshaka | Facebook",
      "link": "https://www.facebook.com/bankalrahamanawad.elshaka/photos"
    },
    {
      "provider": "google",
      "title": "Ahmed Elshaka - Bayt.com",
      "link": "https://people.bayt.com/ahmed-elshaka/"
    }
  ]
}

Live version

omnisearch-api @ Heroku

Installation and getting started

git clone https://github.com/elshaka/omnisearch-rails
cd 'omnisearch-rails'
bundle install

In order for the google search to work, you'd need to setup the environment variables GOOGLE_ENGINE_ID and GOOGLE_API_KEY with valid credentials.

For bing search you'd need to provide a bing subscription key using the environment variable BING_SUBSCRIPTION_KEY

You'd also need a redis instance running, the rails app will try to connect by default to localhost:6379, you can also provide a custon redis url setting the environment variable REDIS_URL before running the rails server.

Environment variables are set in a .env file (you can use the .env.sample as a template to create your own).

You could then run the server like this:

bundle exec rails s

Testing

To run the test suite simply run rspec

bundle exec rspec

Docker image

You can build a docker image of the project by simply running:

docker build . -t omnisearch-rails

Then a simple way to run a container with it could be:

docker run --network host \
--env GOOGLE_ENGINE_ID=<YOUR GOOGLE ENGINE ID> \
--env GOOGLE_API_KEY=<YOUR GOOGLE API KEY> \
--env BING_SUBSCRIPTION_KEY=<YOUR BING SUBSCRIPTION KEY> \
omnisearch-rails

The server should be available at localhost:3000 just as if you would be running it locally.

Technologies used

  • Rails
  • HTTParty
  • Redis
  • Rspec (+ mock-redis)
  • Docker

Author

👤 Eleazar Meza

omnisearch-rails's People

Contributors

elshaka avatar

Watchers

 avatar  avatar

omnisearch-rails's Issues

Bing API requests not working

Currently a get request to the endpoint https://api.bing.microsoft.com/v7.0/search?q=something setting the Ocp-Apim-Subscription-Key header with a valid subscription key returns the following error:

{
    "error": {
        "code": "401",
        "message": "The Search Operation under Web Search API - v7 is not supported with the current subscription key and pricing tier Bing.CustomSearch.F0."
    }
}

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.