Search

Search is key to any useful inventory or successful marketplace.

Stelace Search API lets you leverage your inventory with dynamic matchmaking relying on availability, geography, fuzzy full-text search and relevance, including custom attributes.

All it takes is an API call and a few milliseconds:

stelace.search.list({
  query: 'Deloran'
})

A lot of things happen in parallel behind the scenes. Here are the most important ones:

  • Stelace only considers assets that are available right now by default
  • Full-text search relies on built-in name and description asset properties. As we’ll see it’s very easy to add the custom attributes of your choice.
  • Search is typo-tolerant so that “Delorean” cars will be returned as expected despite the missing “e”
  • Default sorting applies if no order is specified. Stelace search can meet your ranking needs with advanced yet elegant sorting options.

What makes Stelace search powerful is its dynamic nature, leveraging availability concept. Each asset can have several states in the future described by availabilities.

Search by availability and future states

Stelace search can return assets available in the future:

  • during a given period by specifying startDate and endDate
  • with a given quantity available now or over given period
  • around some location.

Date

If you specify startDate and endDate and don’t disable availabilityFilters, only assets available during the full period will show up in results.

If only startDate is specified, all assets having some availability past this date will be returned.

Quantity

If quantity is specified with dates, appropriate number of units have to be available over the related period. Quantity is 1 by default.

Please note that quantity may not be considered depending on you asset type QUANTITY property.

Location

Locations can be passed as a geocoordinate object, used as origin for calculations:

{,
  location: {
    latitude: 34.046713,
    longitude: -118.107380
  },
  maxDistance: 100000
}

You can specify maxDistance in meters to exclude assets too far from origin, set to 150000 by default.

Custom attributes

Upcoming.

Sorting

You can sort your results by price and custom attributes of type number, boolean or text (max 256 chars) in one or several steps. Each additional sort step acts as a tiebreaker.

You just have to provide search object in your API call:

{
  …
  sort: [
    { "_price": "asc" }, // built-ins denoted by trailing _
    { "seatingCapacity": "desc" }
  ]
}

Sort by availability

You may need to get both available and unavailable assets in search results to implement some custom filtering on your side.

To do so you can set availabilityFilters.enabled to false so a built-in boolean attribute available will be added to each asset.

Imagine you want to get available assets first and then order by a custom attribute:

stelace.search.list({
  sort: [
    { _available: 'desc' },
    { someCustomAttribute: 'desc' }
  ],
  availabilityFilters: {
    enabled: false
  }
})

Similar assets or “More like this”

You can use similarToAssetsIds array of asset ids to search for similar assets and still use any other search parameter.

It can be a convenient way to build “more like this” feature for your users, depending on their browsing in your inventory.