API Docs for: 2.2.2
Show:

Search.Builder Class

A builder for constructing Search instances.

Rather than having to manually construct the options and instantiating a Search directly, this builder may be used.

var search = new Search.Builder()
               .withIndexName(myIndex)
               .withQuery(myQuery)
               .withNumRows(10)
               .withCallback(myCallback)
               .build();

Constructor

Search.Builder

()

Methods

build

() Search

Construct a new Search instance.

Returns:

convertDocuments

(
  • convert
)
chainable

Convert values in documents returned by Solr to corresponding Javascript types.

Parameters:

  • convert Boolean

    Solr document values to JS types.

withCallback

(
  • callback
)
chainable

Set the callback to be executed when the operation completes.

Parameters:

  • callback Function

    The callback to execute when the comman completes.

    • err String

      an error message. Will be null if no error.

    • response Object

      the response from Riak (Solr)

      • numFound Number
        The number of documents found.
      • maxScore Number
        The max score value.
      • docs Object
        Array of documents returned from Solr.

withDefaultField

(
  • fieldName
)
chainable

Use the provided field as the default. Overrides the “default_field” setting in the schema file.

Parameters:

  • fieldName String

    the name of the field.

withDefaultOperation

(
  • op
)
chainable

Set the default operation. Allowed settings are either “and” or “or”. Overrides the “default_op” setting in the schema file.

Parameters:

  • op String

    A string containing either "and" or "or".

withFilterQuery

(
  • filterQuery
)
chainable

Filters the search by an additional query scoped to inline fields.

Parameters:

  • filterQuery String

    the filter query.

withIndexName

(
  • indexName
)
chainable

Set the index name used for this search.

Parameters:

  • indexName String

    the name of the yokozuna index

withNumRows

(
  • maxRows
)
chainable

Specify the maximum number of results to return. Riak defaults to 10 if this is not set.

Parameters:

  • maxRows Number

    the maximum number of results to return.

withPresort

(
  • presort
)
chainable

Sorts all of the results by bucket key, or the search score, before the given rows are chosen. This is useful when paginating to ensure the results are returned in a consistent order.

Parameters:

  • presort String

    a string containing either "key" or "score".

withQuery

(
  • queryString
)
chainable

Set the Solr query string. All distributed Solr queries are supported, which actually includes most of the single-node Solr queries.

Parameters:

  • queryString String

    the query

withReturnFields

(
  • fields
)
chainable

Only return the provided fields. Filters the results to only contain the provided fields.

Parameters:

  • fields String

    an array of field names.

withSortField

(
  • sortField
)
chainable

Sort the results on the specified field name. Default is “none”, which causes the results to be sorted in descending order by score.

Parameters:

  • sortField String

    the fieldname to sort the results on.

withStart

(
  • start
)
chainable

Specify the starting result of the query. Useful for pagination. The default is 0.

Parameters:

  • start Number

    the index of the starting result.