response.js

Summary
response.js
bbop.golr.responseGeneric BBOP handler for dealing with the gross parsing of responses from a GOlr server (whereas <golr_conf> deals with the reported configuration).
Functions
responseContructor for a GOlr query response object.
rawreturns a pointer to the initial response object
successSimple return verification of sane response from server.
callback_typeReturn the callback type if it was specified in the query, otherwise return null.
parametersGet the parameter chunk--variable stuff we put in.
parameterGet the parameter chunk--variable stuff we put in.
row_stepReturns the number of rows requested (integer).
total_documentsReturn the total number of documents found.
start_documentReturns the start document for this response as an integer.
end_documentReturns the end document for this response as an integer.
packetReturn the packet number of the current response.
paging_pWhether or not paging is necessary with the given results set.
paging_previous_pWhether or paging backwards is an option right now.
paging_next_pWhether or paging forwards is an option right now.
documentsReturns an array of raw and unprocessed document hashes.
get_docReturns a specified document, in its raw hash form.
get_doc_fieldReturns the value(s) of the requested fields.
get_doc_labelTries to return a label for a document, field, and id combination.
get_doc_highlightReturns the highlighted value(s) of the requested fields.
facet_field_listReturn a count sorted array of the response’s facet fields.
facet_fieldReturn a count-sorted array of a facet field’s response.
facet_countsFor a given facet field, return a hash of that field’s items and their counts.
queryReturn the raw query parameter “q”.
query_filtersA sensible handling of the not-so-great format of “fq” returned by Solr (fq can be irritating single value or irritating array, along with things like “-” in front of values).

bbop.golr.response

Generic BBOP handler for dealing with the gross parsing of responses from a GOlr server (whereas <golr_conf> deals with the reported configuration).  This is not intended to do anything like modeling the data in the store (<golr_manager>), but rather to deal with things like checking for success, what paging would look like, what parameters were passed, etc.

Summary
Functions
responseContructor for a GOlr query response object.
rawreturns a pointer to the initial response object
successSimple return verification of sane response from server.
callback_typeReturn the callback type if it was specified in the query, otherwise return null.
parametersGet the parameter chunk--variable stuff we put in.
parameterGet the parameter chunk--variable stuff we put in.
row_stepReturns the number of rows requested (integer).
total_documentsReturn the total number of documents found.
start_documentReturns the start document for this response as an integer.
end_documentReturns the end document for this response as an integer.
packetReturn the packet number of the current response.
paging_pWhether or not paging is necessary with the given results set.
paging_previous_pWhether or paging backwards is an option right now.
paging_next_pWhether or paging forwards is an option right now.
documentsReturns an array of raw and unprocessed document hashes.
get_docReturns a specified document, in its raw hash form.
get_doc_fieldReturns the value(s) of the requested fields.
get_doc_labelTries to return a label for a document, field, and id combination.
get_doc_highlightReturns the highlighted value(s) of the requested fields.
facet_field_listReturn a count sorted array of the response’s facet fields.
facet_fieldReturn a count-sorted array of a facet field’s response.
facet_countsFor a given facet field, return a hash of that field’s items and their counts.
queryReturn the raw query parameter “q”.
query_filtersA sensible handling of the not-so-great format of “fq” returned by Solr (fq can be irritating single value or irritating array, along with things like “-” in front of values).

Functions

response

bbop.golr.response = function(json_data)

Contructor for a GOlr query response object.

The constructor argument is an object, not a string.

Arguments

json_datathe JSON data (as object) returned from a request

Returns

golr response object

raw

bbop.golr.response.prototype.raw = function()

returns a pointer to the initial response object

Arguments

n/a

Returns

object

success

bbop.golr.response.prototype.success = function()

Simple return verification of sane response from server.

Success caches its return value.

Arguments

n/a

Returns

boolean

callback_type

bbop.golr.response.prototype.callback_type = function()

Return the callback type if it was specified in the query, otherwise return null.  For example “reset” and “response”.

Arguments

n/a

Returns

string (or null)

parameters

bbop.golr.response.prototype.parameters = function()

Get the parameter chunk--variable stuff we put in.

Pretty general, specialized functions are better.

Arguments

n/a

Returns

hash

parameter

bbop.golr.response.prototype.parameter = function(key)

Get the parameter chunk--variable stuff we put in.

Pretty general, specialized functions are better.

Arguments

n/a key - string id for the wanted parameter

Returns

hash, string, whatever is there at that key (otherwise null)

row_step

bbop.golr.response.prototype.row_step = function()

Returns the number of rows requested (integer).

Arguments

n/a

Returns

integer

total_documents

bbop.golr.response.prototype.total_documents = function()

Return the total number of documents found.

Arguments

n/a

Returns

integer

start_document

bbop.golr.response.prototype.start_document = function()

Returns the start document for this response as an integer.

Arguments

n/a

Returns

integer

end_document

bbop.golr.response.prototype.end_document = function()

Returns the end document for this response as an integer.

Arguments

n/a

Returns

integer

packet

bbop.golr.response.prototype.packet = function()

Return the packet number of the current response.

Arguments

n/a

Returns

integer or null (no packet defined)

paging_p

bbop.golr.response.prototype.paging_p = function()

Whether or not paging is necessary with the given results set.

Arguments

n/a

Returns

boolean

paging_previous_p

bbop.golr.response.prototype.paging_previous_p = function()

Whether or paging backwards is an option right now.

Arguments

n/a

Returns

boolean

paging_next_p

bbop.golr.response.prototype.paging_next_p = function()

Whether or paging forwards is an option right now.

Arguments

n/a

Returns

boolean

documents

bbop.golr.response.prototype.documents = function()

Returns an array of raw and unprocessed document hashes.

Arguments

n/a

Returns

hash

get_doc

bbop.golr.response.prototype.get_doc = function(doc_id)

Returns a specified document, in its raw hash form.

Arguments

doc_iddocument identifier either an id (first) or place in the array

Returns

document hash or null

get_doc_field

bbop.golr.response.prototype.get_doc_field = function(doc_id,
field_id)

Returns the value(s) of the requested fields.

Remember that determining whether the returned value is a string or a list is left as an exercise for the reader when using this function.

Arguments

doc_iddocument identifier either an id (first) or place in the array
field_idthe identifier of the field we’re trying to pull

Returns

value or list of values

get_doc_label

bbop.golr.response.prototype.get_doc_label = function(doc_id,
field_id,
item_id)

Tries to return a label for a document, field, and id combination.

WARNING: This function could be potentially slow on large datasets.

Arguments

doc_iddocument identifier either an id (first) or place in the array
field_idthe identifier of the field we’re trying to pull
item_id[optional] the item identifier that we’re trying to resolve; if the field in question is a string or a single-valued list (as opposed to a multi-values list), this argument is not necessary, but it wouldn’t hurt either

Returns

null (not found) or string

get_doc_highlight

bbop.golr.response.prototype.get_doc_highlight = function(doc_id,
field_id,
item)

Returns the highlighted value(s) of the requested fields.

WARNING: This function is a work in progress and will not return multi-valued fields, just the first match it finds.

WARNING: This function could be potentially slow on large datasets.

Arguments

doc_iddocument id
field_idthe identifier of the field we’re trying to pull
itemthe item that we’re looking for the highlighted HTML for

Returns

string of highlight or null if nothing was found

facet_field_list

bbop.golr.response.prototype.facet_field_list = function()

Return a count sorted array of the response’s facet fields.

Arguments

n/a

Returns

list of strings

facet_field

bbop.golr.response.prototype.facet_field = function(facet_name)

Return a count-sorted array of a facet field’s response.

[["foo", 60], ...]

Arguments

facet_namename of the facet to examine

Returns

list of nested lists

facet_counts

bbop.golr.response.prototype.facet_counts = function()

For a given facet field, return a hash of that field’s items and their counts.

Arguments

n/a

Returns

hash of facets to their integer counts

query

bbop.golr.response.prototype.query = function()

Return the raw query parameter “q”.

Arguments

n/a

Returns

string or null

query_filters

bbop.golr.response.prototype.query_filters = function()

A sensible handling of the not-so-great format of “fq” returned by Solr (fq can be irritating single value or irritating array, along with things like “-” in front of values).  Since plus and minus filters are mutually exclusive, we have a return format like:

{field1: {filter1: (true|false), ...}, ...}

Where the true|false value represents a positive (true) or negative (false) filter.

Parameters

n/a

Returns

a hash of keyed hashes

bbop.golr.response = function(json_data)
Contructor for a GOlr query response object.
bbop.golr.response.prototype.raw = function()
returns a pointer to the initial response object
bbop.golr.response.prototype.success = function()
Simple return verification of sane response from server.
bbop.golr.response.prototype.callback_type = function()
Return the callback type if it was specified in the query, otherwise return null.
bbop.golr.response.prototype.parameters = function()
Get the parameter chunk--variable stuff we put in.
bbop.golr.response.prototype.parameter = function(key)
Get the parameter chunk--variable stuff we put in.
bbop.golr.response.prototype.row_step = function()
Returns the number of rows requested (integer).
bbop.golr.response.prototype.total_documents = function()
Return the total number of documents found.
bbop.golr.response.prototype.start_document = function()
Returns the start document for this response as an integer.
bbop.golr.response.prototype.end_document = function()
Returns the end document for this response as an integer.
bbop.golr.response.prototype.packet = function()
Return the packet number of the current response.
bbop.golr.response.prototype.paging_p = function()
Whether or not paging is necessary with the given results set.
bbop.golr.response.prototype.paging_previous_p = function()
Whether or paging backwards is an option right now.
bbop.golr.response.prototype.paging_next_p = function()
Whether or paging forwards is an option right now.
bbop.golr.response.prototype.documents = function()
Returns an array of raw and unprocessed document hashes.
bbop.golr.response.prototype.get_doc = function(doc_id)
Returns a specified document, in its raw hash form.
bbop.golr.response.prototype.get_doc_field = function(doc_id,
field_id)
Returns the value(s) of the requested fields.
bbop.golr.response.prototype.get_doc_label = function(doc_id,
field_id,
item_id)
Tries to return a label for a document, field, and id combination.
bbop.golr.response.prototype.get_doc_highlight = function(doc_id,
field_id,
item)
Returns the highlighted value(s) of the requested fields.
bbop.golr.response.prototype.facet_field_list = function()
Return a count sorted array of the response’s facet fields.
bbop.golr.response.prototype.facet_field = function(facet_name)
Return a count-sorted array of a facet field’s response.
bbop.golr.response.prototype.facet_counts = function()
For a given facet field, return a hash of that field’s items and their counts.
bbop.golr.response.prototype.query = function()
Return the raw query parameter “q”.
bbop.golr.response.prototype.query_filters = function()
A sensible handling of the not-so-great format of “fq” returned by Solr (fq can be irritating single value or irritating array, along with things like “-” in front of values).
Close