Skip to content

Latest commit

 

History

History
95 lines (76 loc) · 2.43 KB

readme.md

File metadata and controls

95 lines (76 loc) · 2.43 KB

Suggest

We use suggest for the auto-completion input fields in isearch-ui and taggy-ui.

Usage

var taggy = require('taggable-searcher');

taggy.suggest({
  text: 'Spa',
  context: 'dk:da',
  include: 'hotel',
  exclude: 'geo',
  start: 0,
  size: 10
}, callback)

API

suggest([params], callback)

params

text

Type: string

This is the text that is used to suggest auto-completion possibilities.
This is a mandatory field.

context

Type: string
Default: taggy

This is a unique identifier to differentiate different markets and languages.
E.g. a Danish context may look like this: dk:da

include

Type: array or string
Default: empty

You can provide an include parameter to only suggest options that have the tagid prefix provided.
E.g. When I search for Spa I only want suggestions related to a geo-location. Then I will have to add geo to the include parameter.

Note: Use include or exclude, but not both.

exclude

Type: array or string
Default: empty

This is the opposite of include.
E.g. When I search for Spa I want suggestions that are not related to a geo-location. Then I will have to add geo to the exclude parameter.

Note: Use include or exclude, but not both.

start

Type: int
Default: 0

Specifies the offset of the first search hit you want to return. Note that the result set is zero-based; the first result is at index 0. You can specify either the start or cursor parameter in a request, they are mutually exclusive.

size

Type: int
default: 10

Specifies the maximum number of search hits to include in the response.

Result

{
    "status": {
        "timems": 0,
        "rid": "8uWhicgq4FwKUJQt"
    },
    "hits": {
        "found": 1,
        "start": 0,
        "hit": [{
            "id": "taggy:geo:geonames.2510769",
            "fields": {
                "name": ["Spain"],
                "tagid": ["geo:geonames.2510769"],
                "label": ["Spain"],
                "context": ["taggy"],
                "active": ["true"],
                "boost": ["1"]
            }
        }]
    }
}

Environment variables

In order for this to work we need to set up 1 environment variable or initialize it manually before we use any function.

variables

CLOUDSEARCH_ENDPOINT The cloudsearch endpoint

manually

taggy.suggest.init('cloud search endpoint');