Class: Search

Search

An api adapter over the end points handling search and character search via functions in the search ESI endpoints. You should not usually instantiate this directly as its constructor requires an internal api instance.

This is a function class so instances of Search are functions and can be invoked directly, besides accessing its members. Its default function action is equivalent to get.


Create a new Search api wrapper with the given configuration. If categories is provided then the search is restricted to those categories, otherwise it will search over all categories. If categories is a single item, the return result of the search is simplified to be the array of ids for that category (instead of an outer object with keys per category).

Categories must from the following enumeration:

  • agent
  • alliance
  • character
  • constellation
  • corporation
  • faction
  • inventorytype
  • region
  • solarsystem
  • station
  • wormhole

If characterId and accessToken are provided then the search will use character specific search end point, and the structure category can also be used.

Parameters:
Name Type Default Description
agent ESIAgent

The ESI agent

categories Array.<String>

Optional; the categories search to through

characterId Number 0

Optional; the character id of the search

accessToken String

Optional; SSO token for the provided character, must be provided if characterId is given

Methods


get(text)

Search for entities that match a given sub-string. This route is cached for up to 3600 seconds.

This makes an HTTP GET request to /search/. The route version is v1.

The string length of text must be at least 3. This function invokes the route with strict set to false.

On success, this resolves to a list of search results. An example result is:

{
  "agent": [
    0
  ],
  "alliance": [
    0
  ],
  "character": [
    0
  ],
  "constellation": [
    0
  ],
  "corporation": [
    0
  ],
  "faction": [
    0
  ],
  "inventorytype": [
    0
  ],
  "region": [
    0
  ],
  "solarsystem": [
    30002510
  ],
  "station": [
    60004588
  ],
  "wormhole": [
    0
  ]
}

However, if the Search instance is configured to search over only a single category then the Promise simply resolves to the array of ids (e.g. the category was fetched from the response dictionary of category to array).

Parameters:
Name Type Description
text String

The string to search on. The search terms of the query

Returns:

Or a Promise.<Array.<Number>> for a single-category search. A Promise that resolves to the parsed JSON of the response.

Type
Promise.<Object>

strict(text)

Search for entities that match a given sub-string. This route is cached for up to 3600 seconds.

This makes an HTTP GET request to /search/. The route version is v1.

The string length of text must be at least 3. This function invokes the route with strict set to true.

On success, this resolves to a list of search results. An example result is:

{
  "agent": [
    0
  ],
  "alliance": [
    0
  ],
  "character": [
    0
  ],
  "constellation": [
    0
  ],
  "corporation": [
    0
  ],
  "faction": [
    0
  ],
  "inventorytype": [
    0
  ],
  "region": [
    0
  ],
  "solarsystem": [
    30002510
  ],
  "station": [
    60004588
  ],
  "wormhole": [
    0
  ]
}

However, if the Search instance is configured to search over only a single category then the Promise simply resolves to the array of ids (e.g. the category was fetched from the response dictionary of category to array).

Parameters:
Name Type Description
text String

The string to search on. The search terms of the query

Returns:

Or a Promise.<Array.<Number>> for a single-category search. A Promise that resolves to the parsed JSON of the response.

Type
Promise.<Object>