This document provides examples on typical query combinations you will use in an application to build unique search experiences. You can always experiment with queries from the query pad in the dashboard.
Specify the name of the class you want to query as string.
Perform a non text query such as filtering on fields such as location, tags, age, price etc. You can review the operators supported in the filter object from the mongodb docs.Example:
Specify the text search. Matching objects returned will be ranked by their relevance to the given query unless the sort attribute is specified.
Specify the fields in the class that should be considered for the search operation. For example if you created a text index on the title and description field, you can specify both fields to be used for the search using this attribute.
An integer value greater than or equal to zero. When this field is set, the parts of the text searched that matches the query will be highlighted and returned as part of the results. A value of zero will return the snippet as is without including any words. If you specify a value greater than zero, an equal amount of words will be added prepended and appended to the snippet returned.
If performing a fuzzy search and any words used to satisfy the query was not an exact match. Setting this field to 1 will return the words that were used in place of the query words. You can use this field to suggest alternate words for your user as typical in the "did you mean the following words instead" feature in search engines.
Use this field to specify the expression used to boost the relevance of an object in the query results. The format of the expression is explained in the examples section. Review examples of the textquery.options.queryboostexpr attibute.
Limit the number of matching objects found for the query
Skip the specified number of objects in the results set
Specify the fields used to order the result set. A value of -1 and 1 are expected and respectively performs a descending and ascending sort
The fields in the class to be included in the result set. A value of 0 and 1 are expected and respectively excludes and includes the specified field.
Join the results set to another query. Joins can be nested into a heirarchy of multiple levels.
When specified, returns the number of objects matching the textquery and filter specified.
|current_score||The current score of the document computed using Nodechef cloud search practical scoring function which uses tf/idf and a coordination factor. This function is similar to lucene's practical scoring function|
|value||Contains the value from the document referenced in the boost.field attribute in the search document. From the above example, value will contain the number_of_votes attribute from each document. Only indexed fields can be referenced. This is crucial for performance.|
|param||Allows you to pass a parameter into the scoring function. This parameter can be of type int32, int64, double, datetime, string and array|
|cache||When set to true, caches the compiled expression for reuse on subsequent queries|