# SearchQuery

## AV. SearchQuery

#### new SearchQuery()

Source:
  - search.js, line 112
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

#### find() → {AV.Promise}

Source:
  - search.js, line 224
See:
  - AV.Query#find

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
  AV.Promise

#### hasMore() → {Boolean}

Source:
  - search.js, line 201
See:
  - AV.SearchQuery#find

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:
  - search.js, line 154

Sets the highlight fields. Such as

      query.highlights('title');
      //or pass an array.
      query.highlights(['title', 'content'])

##### Parameters:

Name | Type | Description
--- | --- | ---
`highlights` | Array.<String> | a list of fields.

##### Returns:

Returns the query, so you can chain this call.

Type
  AV.SearchQuery

#### hits() → {Number}

Source:
  - search.js, line 181

Returns the number of objects that match this query.

##### Returns:

Type
  Number

#### queryString(q) → {AV.SearchQuery}

Source:
  - search.js, line 138

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:
  - search.js, line 209

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:
  - search.js, line 128

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

#### sortBy(builder) → {AV.SearchQuery}

Source:
  - search.js, line 172
See:
  - AV.SearchSortBuilder

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