Golem.de API

Golem  alpha

Golem.de API > Golem > Golem.Api.Article.Search
Search:
 
Filters

Class Golem.Api.Article.Search - extends Golem.Api

Search for articles via Golem web interface

Constructor

Golem.Api.Article.Search ( )

Properties

ERROR_QUERY_TOO_LONG - {Integer}

Indicates that the whole search query is too long

ERROR_TOO_MUCH_WORDS - {Integer}

Indicates that the search query contains too much words

ERROR_WORD_TOO_LONG - {Integer}

Indicates that a word in the search query is too long

ERROR_WORD_TOO_SHORT - {Integer}

Indicates that a word in the search query is too short

itemsPerPage - protected {Integer}

Number of items to list per search page

query - protected {String}

The query to use the search

startIndex - protected {Integer}

Search page to fetch

totalResults - protected {Integer}

Number of total results for a search query

TYPE - protected {String}

The type of access method for the web service

URL - protected {String}

The URL of the used web service

Methods

each

void each ( fnCallback , params )
Traverses through the search list.

After a succesful request you can traverse through the result list. You pass a callback function to the method, and the method is called for each article

The first argument to this callback function is an article object with the properties:

  • articleid - {Integer} - The article identifier
  • headline - {String(60)} - The article headline
  • abstracttext - {String} - The article abstract
  • url - {String} - The article URL
  • date - {Integer} - The article publishing date in microseconds
The second argument will be the data provided by params.

Parameters:
fnCallback <Function> - the callback function to call for each article
params <Mixed> - additional data passed to the callback function
Returns: void

fetch

void fetch ( obj )
Fetches the search results via web service

In case of a successful request, the obj.fnSuccess-callback function will be called. The first argument for the callback method is the result data of the request. The second argument will be the data provided by obj.params.

In case of a failed request, the obj.fnError callback function will be called. The first argument to the callback is the error code, the second ist the error message.

Parameters:
obj <Object> - Object literal specifing the callback methods
Returns: void

fetchEach

void fetchEach ( fnCallback , params )
Shortcut method for traversing the search result.

Fetches the articles via fetch() first and then calls fnCallback for every article record like each() does.

There is no way to handle errors with this method!

Parameters:
fnCallback <Function> - Function to call for every article record
params <Mixed> - additional data to pass to the callback function
Returns: void

getItemsPerPage

Integer getItemsPerPage ( )
Returns the number of result items per page.

The value may be changed after request.

Returns: Integer

getStartIndex

Integer getStartIndex ( )
Returns the page of the result.

The value may be changed after request.

Returns: Integer

getTotalResults

Integer getTotalResults ( )
Returns the total number of results for the search query
Returns: Integer
- the total number of search results

setItemsPerPage

void setItemsPerPage ( itemsPerPage )
Sets the number of result items to fetch per request. The valid value range may depend on the server settings.
Parameters:
itemsPerPage <Integer> - the number of items to fetch
Returns: void

setQuery

void setQuery ( query )
Sets the search query for the request
Parameters:
query <String> - the search query
Returns: void

setStartIndex

void setStartIndex ( startIndex )
Sets the page to fetch.
Parameters:
startIndex <Integer> - the page number
Returns: void


Copyright © 2010 Golem.de.