SearchQuery

AV. SearchQuery

new SearchQuery()

Source:
Since:
  • 0.5.1
App searching query.Use just like AV.Query: Visit App Searching Guide for more details.
Example
var query = new AV.SearchQuery('Player');
  query.queryString('*');
  query.find().then(function(results) {
    console.log('Found %d objects', query.hits());
    //Process results
  });

Methods

addAscending(key) → {AV.SearchQuery}

Source:
Also sorts the results in ascending order by the given key. The previous sort keys have precedence over this key.
Parameters:
Name Type Description
key String The key to order by
Returns:
Returns the query so you can chain this call.
Type
AV.SearchQuery

addDescending(key) → {AV.SearchQuery}

Source:
Also sorts the results in descending order by the given key. The previous sort keys have precedence over this key.
Parameters:
Name Type Description
key String The key to order by
Returns:
Returns the query so you can chain this call.
Type
AV.SearchQuery

ascending(key) → {AV.SearchQuery}

Source:
Sorts the results in ascending order by the given key.
Parameters:
Name Type Description
key String The key to order by.
Returns:
Returns the query, so you can chain this call.
Type
AV.SearchQuery

descending(key) → {AV.SearchQuery}

Source:
Sorts the results in descending order by the given key.
Parameters:
Name Type Description
key String The key to order by.
Returns:
Returns the query, so you can chain this call.
Type
AV.SearchQuery

find() → {Promise}

Source:
See:
Retrieves a list of AVObjects that satisfy this query. Either options.success or options.error is called when the find completes.
Returns:
A promise that is resolved with the results when the query completes.
Type
Promise

hasMore() → {Boolean}

Source:
See:
Returns true when there are more documents can be retrieved by this query instance, you can call find function to get more results.
Returns:
Type
Boolean

highlights(highlights) → {AV.SearchQuery}

Source:
Sets the highlight fields. Such as

  query.highlights('title');
  //or pass an array.
  query.highlights(['title', 'content'])
Parameters:
Name Type Description
highlights String | Array.<String> a list of fields.
Returns:
Returns the query, so you can chain this call.
Type
AV.SearchQuery

hits() → {Number}

Source:
Returns the number of objects that match this query.
Returns:
Type
Number

include(keys) → {AV.SearchQuery}

Source:
Include nested AV.Objects for the provided key. You can use dot notation to specify which fields in the included object are also fetch.
Parameters:
Name Type Description
keys Array.<String> The name of the key to include.
Returns:
Returns the query, so you can chain this call.
Type
AV.SearchQuery

limit(n) → {AV.SearchQuery}

Source:
Sets the limit of the number of results to return. The default limit is 100, with a maximum of 1000 results being returned at a time.
Parameters:
Name Type Description
n Number the number of results to limit to.
Returns:
Returns the query, so you can chain this call.
Type
AV.SearchQuery

queryString(q) → {AV.SearchQuery}

Source:
Sets the query string of app searching.
Parameters:
Name Type Description
q String The query string.
Returns:
Returns the query, so you can chain this call.
Type
AV.SearchQuery

reset()

Source:
Reset current query instance state(such as sid, hits etc) except params for a new searching. After resetting, hasMore() will return true.

sid(sid) → {AV.SearchQuery}

Source:
Sets the sid of app searching query.Default is null.
Parameters:
Name Type Description
sid String Scroll id for searching.
Returns:
Returns the query, so you can chain this call.
Type
AV.SearchQuery

skip(n) → {AV.SearchQuery}

Source:
Sets the number of results to skip before returning any results. This is useful for pagination. Default is to skip zero results.
Parameters:
Name Type Description
n Number the number of results to skip.
Returns:
Returns the query, so you can chain this call.
Type
AV.SearchQuery

sortBy(builder) → {AV.SearchQuery}

Source:
See:
Sets the sort builder for this query.
Parameters:
Name Type Description
builder AV.SearchSortBuilder The sort builder.
Returns:
Returns the query, so you can chain this call.
Type
AV.SearchQuery