rails-gsa

A rubygem which allows you to integrate GSA(Google Search Appliance) with your ruby/rails application

Features

Install

gem install rails-gsa

Usage

Get JSON Response

RailsGSA.search(:gsa_url => "http://testgsa.com", :search_term => "hello", :output => "json")
# where,
# gsa_url is the domain of your GSA
# search_term is the query
# output is the expected response type

Here a request will be sent to your GSA and the recieved JSON response will be parsed and returned to you as a Hash

Get XML Response

RailsGSA.search(:gsa_url => "http://testgsa.com", :search_term => "hello", :output => "xml")

Here a request will be sent to your GSA and the recieved XML response will be parsed and returned to you as a Hash

Modify Access Level

Specifies whether to search public content, secure content, or both.

# Default Value: "p"
RailsGSA.search(:gsa_url => "http://testgsa.com", :search_term => "hello", :access => "s")
# Possible values for the access parameter are:
# p - search only public content 
# s - search only secure content 
# a - search all content, both public and secure

Change the Collection

Limits search results to the contents of the specified collection. You can search multiple collections by separating collection names with the OR character, which is notated as the pipe symbol, or the AND character, which is notated as a period. If a user submits a search query without the site parameter, the entire search index is queried.

# Default Value: "default_collection"
RailsGSA.search(:gsa_url => "http://testgsa.com", :search_term => "hello", :site => "myCollection")

# You can also specify whether you want to search results in multiple collections as given below:

# The following example uses the AND character:
RailsGSA.search(:gsa_url => "http://testgsa.com", :search_term => "hello", :site => "col1.col2")

# The following example uses the OR character:
RailsGSA.search(:gsa_url => "http://testgsa.com", :search_term => "hello", :site => "col1|col2")

Pagination

You can use the pagination parameters to get results as you desire

RailsGSA.search(:gsa_url => "http://testgsa.com", :search_term => "hello", :start => 10, :num => 20)
# Default value: start = 0; num = 10

The above example will give you results starting from 10 and the next 20 results. The maximum number of results available for a query is 1,000, i.e., the value of the start parameter added to the value of the num parameter cannot exceed 1,000.

Issues and Suggestions

Please report all the issues in the Github Issues Page, suggestions are also welcome. You can also mail me at rohit0981989@gmail.com for the same.