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
()
Item Index
Methods
convertDocuments
-
convert
Convert values in documents returned by Solr to corresponding Javascript types.
Parameters:
-
convertBooleanSolr document values to JS types.
withCallback
-
callback
Set the callback to be executed when the operation completes.
Parameters:
-
callbackFunctionThe callback to execute when the comman completes.
-
errStringan error message. Will be null if no error.
-
responseObjectthe response from Riak (Solr)
-
numFoundNumberThe number of documents found. -
maxScoreNumberThe max score value. -
docsObjectArray of documents returned from Solr.
-
-
withDefaultField
-
fieldName
Use the provided field as the default. Overrides the “default_field” setting in the schema file.
Parameters:
-
fieldNameStringthe name of the field.
withDefaultOperation
-
op
Set the default operation. Allowed settings are either “and” or “or”. Overrides the “default_op” setting in the schema file.
Parameters:
-
opStringA string containing either "and" or "or".
withFilterQuery
-
filterQuery
Filters the search by an additional query scoped to inline fields.
Parameters:
-
filterQueryStringthe filter query.
withIndexName
-
indexName
Set the index name used for this search.
Parameters:
-
indexNameStringthe name of the yokozuna index
withNumRows
-
maxRows
Specify the maximum number of results to return. Riak defaults to 10 if this is not set.
Parameters:
-
maxRowsNumberthe maximum number of results to return.
withPresort
-
presort
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:
-
presortStringa string containing either "key" or "score".
withQuery
-
queryString
Set the Solr query string. All distributed Solr queries are supported, which actually includes most of the single-node Solr queries.
Parameters:
-
queryStringStringthe query
withReturnFields
-
fields
Only return the provided fields. Filters the results to only contain the provided fields.
Parameters:
-
fieldsStringan array of field names.
withSortField
-
sortField
Sort the results on the specified field name. Default is “none”, which causes the results to be sorted in descending order by score.
Parameters:
-
sortFieldStringthe fieldname to sort the results on.
withStart
-
start
Specify the starting result of the query. Useful for pagination. The default is 0.
Parameters:
-
startNumberthe index of the starting result.
