Query DataGetting Started with Managed Fusion
This topic details how to use Query Workbench to configure search results, including faceting. Facets are categories or features offered as filters within a search results page.
Before you begin
To perform the steps in this part of the tutorial, you must first complete Part 1 - Create a Managed Fusion application and Part 2 - Index Data.
The dataset created in the previous sections of the tutorial has three fields that users of your search application might find relevant:
-
genres_ss
. A list of one or more genre labels. -
title_txt
. The name of the movie. -
year_i
. The movie’s year of release.
The field suffixes indicate the type of data stored in each field:
-
Fields with the suffix
_ss
(multivalued string fields) contain one or more string values.String fields require an exact match between the query string and the string value stored in that field.
-
Fields with the suffix
_txt
(text fields) contain text.Text fields allow for free text search of the field contents. For example, because the movie titles are stored in a text field, a search on the word "Star" will match movies titled "Star", "A Star is Born", all movies in the Star Wars and Star Trek franchises, as well as "Dark Star", "Lone Star", and "Star Kid".
-
Fields with the suffix
_i
(point integer fields) contain integer values.Numeric fields allow range matches as well as exact matches, and point integer fields allow efficient comparisons between the field’s values and the search criteria.
The different field types allow for various searches. Configuration of the query pipeline determines how fields are searched.
Explore search results
Query Workbench lets you configure a query pipeline and preview the search results it produces. A query pipeline converts a free text query submitted to your search application into a structured query for Solr.
-
Sign in to Managed Fusion if it is not currently open.
-
In the Managed Fusion launcher, click the Movie Search app.
-
Click Querying
> Query Workbench.
Perform a search
The default search is the wildcard search (*:*
), which returns all documents in the collection.
For information about other search entries for facets, see search entry options.
-
In the search box, enter the query string
star
, and press Enter or click Search.
This search returns all movies that have the word "star" in the title.
The output is configured by the default query pipeline, which has the same name as the collection. In this example, the name is
movie-search
.To view more of the default output, you can perform other searches.
-
In the search box, enter the query string
*:*
to return all documents, and press Enter or click Search.
To refine your results, change your index pipeline configuration and reindex your data. |
Explore the role of query pipeline stages
A default query pipeline includes the following stages:
-
Boost with Signals. Use signals data to boost relevant documents. For more information, see collaborative filtering.
-
Query Fields. Specify the set of fields over which to search.
-
Field Facet. Specify the fields to use for faceting.
-
Text Tagger. Search for information such as known phrases, synonyms, and misspellings that can be used to improve the query with query rewriting.
-
Apply Rules. Modify the query using business rules, if any are triggered.
-
Solr Query. Perform the query and return the results.
This is the only stage that is always required to perform a query and receive results.
-
Modify Response with Rules. Modify Solr’s response using business rules, if any are triggered.
To preview how results are affected by different stages:
-
Click the green circle next to the Solr Query stage to turn off the stage.
All search results disappear from the preview pane because Managed Fusion does not send a query to Solr.
-
Turn on the Solr Query stage and turn all other stages off.
Now the search results look much like they did before. At this point, the disabled stages do not affect the output because they are not yet configured.
-
Turn all stages on.
Configure faceting
Facets:
-
Are categories or features offered as filters within a search results page.
-
Provide a simple way for users to explore and filter their search results without having to construct complicated queries.
-
Can be configured when you also configure a query pipeline.
The data already indexed in the tutorial has two fields that are natural choices for faceting: genres_ss
and year_i
. For example, a user could search for science fiction of the 1950s in just a few clicks.
Configure basic faceting for genres
-
Click Add a field facet and select the
genres_ss
field. -
Click Sci-Fi to select movies that have the value
Sci-Fi
forgenres_ss
:Genres are not in any specific order. In configuration for the Field Facet stage, you can choose a value of Sort for the facet field. Sort options are index
(alphabetical ascending order) orcount
(number of documents). You can also add field facets by configuring the Field Facet stage. -
Under the field facet genres_ss, click Clear all.
Configure range faceting for years
If you configure faceting for the year_i
field as you did above for the genres_ss
field, you would get one facet per year, which is not very useful.
The year_i
field will be more usable if you configure range faceting. Range faceting is a way of grouping values together so that the user can select a value range instead of one specific value. For example, range facets are commonly used with pricing ($50-$100) or ratings (4 stars or higher). In this example, you will group years by decade.
Range faceting requires sending an additional query parameter to Managed Fusion’s Solr core. You can configure this with the Additional Query Parameters stage. In this case, you will use several of Solr’s range facet query parameters.
Use the Additional Query Parameters stage to configure range faceting for the year_i
field:
-
Click Add a stage.
-
Scroll down, and in Advanced, select Additional Query Parameters.
The Additional Query Parameters configuration panel displays.
-
Under Parameters and Values, add the following parameter names and values:
Parameter Name Parameter Value facet.range
year_i
facet.range.start
1900
facet.range.end
2020
facet.range.gap
10
facet.range.include
outer
In this case, you do not need to modify the Update Policy field. The default value of
append
does not affect these results. -
Click Apply, and then click Cancel to close the configuration panel for the Additional Query Parameters stage.
The year facets are now grouped by decade:
Facets are not the only way for users to find items by year. In your user application, you can let users search for specific values in the year_i
field such as using the text field or dropdown list.
Configure query fields
To specify fields to match a particular query:
-
Search for "2001".
The results are not what an end user might expect because "2001: A Space Odyssey" is not the top search result.
-
Under one of the movies listed, click show fields.
The reason "2001: A Space Odyssey" is not the top search result is because your search query matches the
id
field. This field may not be useful to your users.Use the Query Fields stage to specify the fields that may be a higher priority for users.
-
Below the name for the movie you selected, click hide fields.
-
Click the Query Fields stage of the query pipeline.
The Query Fields configuration panel displays.
-
Under Search Fields, click Add
.
-
Enter
title_txt
. -
Click Add
again.
-
Enter
year_i
. -
Click Apply, and then click Cancel to close the configuration panel for the Query Fields stage.
Now movies with '2001' in their title rise to the top of your search results, followed by films made in the year 2001:
-
In the upper right, click Save to save the changes to the query pipeline.
Next steps
In Part 4 - Improve relevancy, you will enable signals, generate some signal data, aggregate it, search it, and review results. Signals can be used for recommendations or boosting.