This is an old version of the documentation. Follow to go to the new Manticore Search manual.

No, thanks
  • Downloads
  • Services
  • Resources

    • Documentation
    • Cheatsheets
    • Courses
    • Free Config Review
    • Blog
    • Forum
  • About

    • Manticore Search
    • Clients
  • Contact
3.2.0

Manticore Documentation

  • Introduction
  • Gettting Started
    • Getting started using Docker container
      • Installing and running
      • Running queries
      • Using plain indexes
    • Getting Started using official packages
      • Installing and running
      • Running queries
      • Using plain indexes
    • Migrating from Manticore or Sphinx Search 2.x
      • Index storage engine
      • Kill-list
      • Removed configuration keys
      • Updating var-length attributes
      • Document IDs
    • A guide on configuration file
      • Special suffixes
      • Scripting support
      • Comments
      • Inheritance of index and source declarations
    • A guide on connectivity
      • SphinxAPI protocol
      • SphinxQL protocol
        • MySQL Connectors
        • ODBC
      • HTTP API protocol
    • A guide on indexes
      • Plain indexes
      • Real-Time indexes
      • Local distributed indexes
      • Remote distributed indexes and high availability
      • Replication and cluster
    • A guide on searching
      • Running queries
      • Fulltext Matching
      • Ranking fulltext matches
      • Data tokenization
      • Multi-threaded searching
      • Grouping and faceting
      • Functions
      • Highlighting
      • Tokenizer tester
      • Suggested words
      • Percolate queries
      • Search performance
  • Installation
    • Installing Manticore packages on Debian and Ubuntu
    • Installing Manticore packages on RedHat and CentOS
      • Installing Manticore Search from Manticore yum repository
      • Install Manticore Search using downloaded rpm packages
      • Starting Manticore Search
    • Installing Manticore on Windows
    • Installing Manticore on MacOS
    • Upgrading from Sphinx Search
    • Running Manticore Search in a Docker Container
      • Starting a Manticore Search instance in a container
      • Mounting points
    • Compiling Manticore from source
      • Required tools
      • Required libraries/packages on Linux
      • Optional dependencies
      • General building options
      • Compiling on Linux systems
      • Compiling on Windows
      • Compiling on FreeBSD
      • Recompilation (update)
    • Quick Manticore usage tour
  • Indexing
    • Indexes
      • Plain indexes
      • Real-Time indexes
      • Distributed indexes
      • Templates indexes
      • Percolate indexes
      • Index files
      • Accessing index files
      • Operations on indexes
        • Declaration
        • Loading or discarding indexes
        • Index changes
    • Data Types
      • Document ID
      • Text
      • String
      • Integer
      • Big Integer
      • Timestamps
      • Float
      • JSON
      • Multi-value integer
      • Multi-value big integer
    • Full-text fields
    • Attributes
      • Example sphinx.conf part:
      • Example application code (in PHP):
    • MVA (multi-valued attributes)
    • Restrictions on the source data
    • Charsets, case folding, translation tables, and replacement rules
    • Data sources
    • SQL data sources (MySQL, PostgreSQL)
      • Ranged queries
      • sql_query_post vs. sql_query_post_index
    • xmlpipe2 data source
    • TSV/CSV data source
    • Live index updates
    • Delta index updates
    • Index merging
  • Real-time indexes
    • RT indexes overview
    • Known caveats with RT indexes
    • RT index internals
    • Binary logging
  • Searching
    • Matching modes
    • Boolean query syntax
    • Escaping characters in search queries
    • Extended query syntax
    • Search results ranking
      • Ranking overview
      • Available built-in rankers
        • Legacy matching modes rankers
      • Quick summary of the ranking factors
      • Document-level ranking factors
      • Field-level ranking factors
      • Ranking factor aggregation functions
      • Formula expressions for all the built-in rankers
    • Expressions, functions, and operators
      • Operators
      • Numeric functions
      • Date and time functions
      • Type conversion functions
      • Comparison functions
      • Miscellaneous functions
    • Sorting modes
      • SPH_SORT_TIME_SEGMENTS mode
      • SPH_SORT_EXTENDED mode
      • SPH_SORT_EXPR mode
    • Grouping (clustering) search results
    • Distributed searching
    • Query log formats
      • Plain log format
      • SphinxQL log format
    • MySQL protocol support and SphinxQL
    • Multi-queries
    • Faceted search
      • Aggregations
      • Returned result set
      • Performance
    • Geo Searching
      • Performing distance calculation
      • Searching in polygons
    • Collations
    • Query cache
    • MySQL storage engine (SphinxSE)
      • SphinxSE overview
        • Installing SphinxSE
        • Compiling MySQL 5.0.x with SphinxSE
        • Compiling MySQL 5.1.x with SphinxSE
        • Checking SphinxSE installation
        • Using SphinxSE
      • Building snippets (excerpts) via MySQL
    • MySQL FEDERATED storage engine support
      • MySQL FEDERATED overview
      • Using FEDERATED
    • Percolate query
      • The percolate index
        • ID
        • Query
        • Filters
        • Tags
      • Index schemas
      • Store queries
      • List stored queries
      • Delete queries
      • Search matching queries
      • Meta
      • Reconfigure
      • Distributed indexes made from percolate locals and/or agents (DPQ indexes)
  • Extending
    • UDFs (User Defined Functions)
    • Plugins
    • Ranker plugins
    • Token filter plugins
      • Index-time tokenizer
      • query-time token filter
  • Replication
    • Replication cluster
      • name
      • path
      • nodes
      • options
    • Creating a cluster
    • Joining a cluster
    • Deleting a cluster
    • Managing indexes
    • Managing nodes
    • Write statements
    • Cluster status
    • Cluster parameters
    • Restarting a cluster
    • Cluster with diverged nodes
      • How to recover a cluster
        • Case 1
        • Case 2
        • Case 3
        • Case 4
        • Case 5
        • Case 6
        • Case 7
  • Command line tools reference
    • index_converter command reference
    • indexer command reference
    • indextool command reference
    • searchd command reference
    • spelldump command reference
    • wordbreaker command reference
  • SphinxQL reference
    • ALTER syntax
    • ATTACH INDEX syntax
    • BEGIN, COMMIT, and ROLLBACK syntax
    • BEGIN syntax
    • CALL KEYWORDS syntax
    • CALL PQ syntax
      • Distributed PQ modes
    • CALL QSUGGEST syntax
    • CALL SNIPPETS syntax
    • CALL SUGGEST syntax
    • Comment syntax
    • CREATE FUNCTION syntax
    • CREATE PLUGIN syntax
    • DEBUG syntax
    • DELETE syntax
    • DESCRIBE syntax
      • Percolate index schemas
    • DROP FUNCTION syntax
    • DROP PLUGIN syntax
    • FLUSH ATTRIBUTES syntax
    • FLUSH HOSTNAMES syntax
    • FLUSH LOGS syntax
    • FLUSH RAMCHUNK syntax
    • FLUSH RTINDEX syntax
    • INSERT and REPLACE syntax
      • RT index INSERT features
      • Percolate index INSERT features
    • List of SphinxQL reserved keywords
    • Multi-statement queries
    • OPTIMIZE INDEX syntax
    • RELOAD INDEX syntax
    • RELOAD INDEXES syntax
    • RELOAD PLUGINS syntax
    • REPLACE syntax
    • ROLLBACK syntax
    • SELECT syntax
      • Column list
      • EXIST()
      • SNIPPET()
      • REMOVE_REPEATS()
      • FROM
      • WHERE
      • GROUP BY
      • GROUP_CONCAT()
      • ZONESPANLIST()
      • WITHIN GROUP ORDER BY
      • HAVING
      • ORDER BY
      • LIMIT
      • OPTION
      • FACET
      • Subselects
    • SELECT @@system_variable syntax
    • SET syntax
    • SET TRANSACTION syntax
    • SHOW AGENT STATUS
    • SHOW CHARACTER SET syntax
    • SHOW COLLATION syntax
    • SHOW DATABASES syntax
    • SHOW INDEX SETTINGS syntax
    • SHOW INDEX STATUS syntax
    • SHOW META syntax
    • SHOW PLAN syntax
    • SHOW PLUGINS syntax
    • SHOW PROFILE syntax
    • SHOW STATUS syntax
    • SHOW TABLES syntax
    • SHOW THREADS syntax
    • SHOW VARIABLES syntax
    • SHOW WARNINGS syntax
    • TRUNCATE RTINDEX syntax
    • UPDATE syntax
  • HTTP API reference
    • /sql API
    • /json API
      • json/bulk
      • json/delete
      • json/insert
      • json/pq
        • Store query
        • Search matching document
        • List stored queries
        • Delete stored queries
      • json/replace
      • json/search
        • Fulltext queries
        • Bool queries
        • Filters
        • Sorting
        • Expressions
        • Text highlighting
        • Result set format
        • Query profile
      • json/update
    • SSL
      • Generating SSL files
        • Generate the CA key
        • Generate the CA certificate from the CA key
        • Server Certificate
  • API reference
    • General API functions
      • GetLastError
      • GetLastWarning
      • SetServer
      • SetConnectTimeout
      • SetArrayResult
      • IsConnectError
    • General query settings
      • SetSelect
      • SetLimits
      • SetMaxQueryTime
      • SetOverride
    • Full-text search query settings
      • SetFieldWeights
      • SetIndexWeights
      • SetMatchMode
      • SetRankingMode
      • SetSortMode
      • SetWeights
    • Result set filtering settings
      • SetFilter
      • SetFilterRange
      • SetFilterFloatRange
      • SetFilterString
      • SetIDRange
      • SetGeoAnchor
    • GROUP BY settings
      • SetGroupBy
      • SetGroupDistinct
    • Querying
      • AddQuery
      • Query
      • RunQueries
      • ResetFilters
      • ResetGroupBy
    • Additional functionality
      • BuildExcerpts
      • BuildKeywords
      • EscapeString
      • FlushAttributes
      • Status
      • UpdateAttributes
    • Persistent connections
      • Open
      • Close
  • Configuration reference
    • Common section configuration options
      • lemmatizer_base
      • progressive_merge
      • json_autoconv_keynames
      • json_autoconv_numbers
      • on_json_attr_error
      • plugin_dir
      • icu_data_dir
    • Data source configuration options
      • csvpipe_delimiter
      • mssql_winauth
      • mysql_connect_flags
      • mysql_ssl_cert, mysql_ssl_key, mysql_ssl_ca
      • odbc_dsn
      • sql_attr_bigint
      • sql_attr_bool
      • sql_attr_float
      • sql_attr_json
      • sql_attr_multi
      • sql_attr_string
      • sql_attr_timestamp
      • sql_attr_uint
      • sql_column_buffers
      • sql_db
      • sql_field_string
      • sql_file_field
      • sql_host
      • sql_joined_field
      • sql_pass
      • sql_port
      • sql_query_killlist
      • sql_query_post_index
      • sql_query_post
      • sql_query_pre
      • sql_query_range
      • sql_query
      • sql_ranged_throttle
      • sql_range_step
      • sql_sock
      • sql_user
      • type
      • unpack_mysqlcompress_maxsize
      • unpack_mysqlcompress
      • unpack_zlib
      • xmlpipe_attr_bigint
      • xmlpipe_attr_bool
      • xmlpipe_attr_float
      • xmlpipe_attr_json
      • xmlpipe_attr_multi_64
      • xmlpipe_attr_multi
      • xmlpipe_attr_string
      • xmlpipe_attr_timestamp
      • xmlpipe_attr_uint
      • xmlpipe_command
      • xmlpipe_field
      • xmlpipe_field_string
      • xmlpipe_fixup_utf8
    • Index configuration options
      • access_plain_attrs
      • access_blob_attrs
      • access_doclists
      • access_hitlists
      • agent_blackhole
      • agent_connect_timeout
      • agent_persistent
      • agent_query_timeout
      • agent_retry_count
      • agent
        • Agent mirrors
      • attr_update_reserve
      • bigram_freq_words
      • bigram_index
      • blend_chars
      • blend_mode
      • charset_table
      • dict
      • docstore_block_size
      • docstore_compression
      • docstore_compression_level
      • embedded_limit
      • exceptions
      • expand_keywords
      • global_idf
      • ha_strategy
        • Simple random balancing
        • Adaptive randomized balancing
        • Round-robin balancing
      • hitless_words
      • html_index_attrs
      • html_remove_elements
      • html_strip
      • ignore_chars
      • index_exact_words
      • index_field_lengths
      • index_sp
      • index_token_filter
      • index_zones
      • infix_fields
      • inplace_enable
      • inplace_hit_gap
      • inplace_reloc_factor
      • inplace_write_factor
      • killlist_target
      • local
      • max_substring_len
      • min_infix_len
      • min_prefix_len
      • min_stemming_len
      • min_word_len
      • mirror_retry_count
      • mlock
      • morphology
      • morphology_skip_fields
      • ngram_chars
      • ngram_len
      • ondisk_attrs
      • overshort_step
      • path
      • phrase_boundary
      • phrase_boundary_step
      • prefix_fields
      • preopen
      • read_buffer_docs
      • read_buffer_hits
      • regexp_filter
      • rt_attr_bigint
      • rt_attr_bool
      • rt_attr_float
      • rt_attr_json
      • rt_attr_multi_64
      • rt_attr_multi
      • rt_attr_string
      • rt_attr_timestamp
      • rt_attr_uint
      • rt_field
      • rt_mem_limit
      • source
      • stopwords
      • stopword_step
      • stopwords_unstemmed
      • stored_fields
      • type
      • wordforms
    • indexer program configuration options
      • lemmatizer_cache
      • max_file_field_buffer
      • max_iops
      • max_iosize
      • max_xmlpipe2_field
      • mem_limit
      • on_file_field_error
      • write_buffer
    • searchd program configuration options
      • access_plain_attrs
      • access_blob_attrs
      • access_doclists
      • access_hitlists
      • agent_connect_timeout
      • agent_query_timeout
      • agent_retry_count
      • agent_retry_delay
      • attr_flush_period
      • binlog_flush
      • binlog_max_log_size
      • binlog_path
      • client_timeout
      • collation_libc_locale
      • collation_server
      • data_dir
      • dist_threads
      • docstore_cache_size
      • expansion_limit
      • grouping_in_utc
      • ha_period_karma
      • ha_ping_interval
      • hostname_lookup
      • listen_backlog
      • listen
      • listen_tfo
      • log
      • max_batch_queries
      • max_children
      • max_filters
      • max_filter_values
      • max_open_files
      • max_packet_size
      • mysql_version_string
      • net_workers
      • net_wait_tm
      • net_throttle_accept
      • net_throttle_action
      • node_address
      • ondisk_attrs_default
      • persistent_connections_limit
      • pid_file
      • predicted_time_costs
      • preopen_indexes
      • qcache_max_bytes
      • qcache_thresh_msec
      • qcache_ttl_sec
      • query_log_format
      • query_log_min_msec
      • query_log
      • query_log_mode
      • queue_max_length
      • read_buffer
      • read_buffer_docs
      • read_buffer_hits
      • read_timeout
      • read_unhinted
      • rt_flush_period
      • rt_merge_iops
      • rt_merge_maxiosize
      • seamless_rotate
      • server_id
      • shutdown_timeout
      • shutdown_token
      • snippets_file_prefix
      • sphinxql_state
      • sphinxql_timeout
      • ssl_ca
      • ssl_cert
      • ssl_key
      • subtree_docs_cache
      • subtree_hits_cache
      • thread_stack
      • unlink_old
      • watchdog
      • workers
  • Reporting bugs
    • Bug-tracker
    • Crashes
    • Core dumps
    • Uploading your data
  • Release notes
    • Version 3.2.0, 17 October 2019
      • Features
      • Improvements and changes
      • Bugfixes
    • Version 3.1.2, 22 August 2019
      • Features and Improvements
      • Bugfixes
    • Version 3.1.0, 16 July 2019
      • Features and Improvements
      • Removals
      • Bugfixes
    • Version 3.0.2, 31 May 2019
      • Improvements
      • Removals
      • Deprecations
      • Bugfixes
    • Version 3.0.0, 6 May 2019
      • Features and improvements
      • Behaviour changes
      • Removed directives
    • Version 2.8.2 GA, 2 April 2019
      • Features and improvements
      • Compiling notes
      • Bugfixes
    • Version 2.8.1 GA, 6 March 2019
      • Features and improvements
      • Bugfixes
    • Version 2.8.0 GA, 28 January 2019
      • Improvements
      • Bugfixes
    • Version 2.7.5 GA, 4 December 2018
      • Improvements
      • Bugfixes
    • Version 2.7.4 GA, 1 November 2018
      • Improvements
      • Bugfixes
    • Version 2.7.3 GA, 26 September 2018
      • Improvements
      • Bugfixes
    • Version 2.7.2 GA, 27 August 2018
      • Improvements
      • Bugfixes
    • Version 2.7.1 GA, 4 July 2018
      • Improvements
      • Bugfixes
    • Version 2.7.0 GA, 11 June 2018
      • Improvements
      • Bugfixes
    • Version 2.6.4 GA, 3 May 2018
      • Features and improvements
      • Bugfixes
    • Version 2.6.3 GA, 28 March 2018
      • Improvements
      • Bugfixes
    • Version 2.6.2 GA, 23 February 2018
      • Improvements
      • Bugfixes
    • Version 2.6.1 GA, 26 January 2018
      • Improvements
      • Bugfixes
    • Version 2.6.0, 29 December 2017
      • Features and improvements
      • Bugfixes
      • Upgrade
    • Version 2.5.1, 23 November 2017
      • Features and improvements
      • Bugfixes
    • Version 2.4.1 GA, 16 October 2017
      • Features and improvements
      • Compiling
      • Folders and service
      • Bugfixes
    • Version 2.3.3, 06 July 2017

Looking for the Cheatsheets?

Download

Manticore Search
  • Docs »
  • Searching »
  • Faceted search

Faceted search¶

In addition to the standard set of search results, a faceted search provides facet results from dynamic clustering of items or search results into categories. Facets allow users to navigate the search query by narrowing it using the facet results.

In Manticore, facets can be added to any query and the facet can be any attribute or an expression. A facet results contains the facet values along with the facet counts. Facets are available using SphinxQL SELECT statement by declaring them at the very end of the query in the format:

FACET {expr_list} [BY {expr_list}] [ORDER BY {expr | FACET()} {ASC | DESC}] [LIMIT [offset,] count]

Multiple facet declarations need to be separate by an whitespace.

Aggregations¶

The facet values can come from an attribute, JSON property from a JSON attribute or expression. Facet values can be also aliased, however the alias must be unique across all result sets (main query results set and other facets results sets). The facet value is taken from the aggregated attribute/expression, but it can also come from another attribute/expression.

MySQL [(none)]> SELECT *, price as aprice FROM facetdemo LIMIT 10 FACET price LIMIT 10 FACET brand_id LIMIT 5;
+------+-------+----------+---------------------+------------+-------------+---------------------------------------+------------+--------+
| id   | price | brand_id | title               | brand_name | property    | j                                     | categories | aprice |
+------+-------+----------+---------------------+------------+-------------+---------------------------------------+------------+--------+
|    1 |   306 |        1 | Product Ten Three   | Brand One  | Six_Ten     | {"prop1":66,"prop2":91,"prop3":"One"} | 10,11      |    306 |
|    2 |   400 |       10 | Product Three One   | Brand Ten  | Four_Three  | {"prop1":69,"prop2":19,"prop3":"One"} | 13,14      |    400 |
...
|    9 |   560 |        6 | Product Two Five    | Brand Six  | Eight_Two   | {"prop1":90,"prop2":84,"prop3":"One"} | 13,14      |    560 |
|   10 |   229 |        9 | Product Three Eight | Brand Nine | Seven_Three | {"prop1":84,"prop2":39,"prop3":"One"} | 12,13      |    229 |
+------+-------+----------+---------------------+------------+-------------+---------------------------------------+------------+--------+
10 rows in set (0.00 sec)
+-------+----------+
| price | count(*) |
+-------+----------+
|   306 |        7 |
|   400 |       13 |
...
|   229 |        9 |
|   595 |       10 |
+-------+----------+
10 rows in set (0.00 sec)
+----------+----------+
| brand_id | count(*) |
+----------+----------+
|        1 |     1013 |
|       10 |      998 |
|        5 |     1007 |
|        8 |     1033 |
|        7 |      965 |
+----------+----------+
5 rows in set (0.00 sec)

Data can be faceted by aggregating another attribute or expression. For example if the documents contain both the brand id and name, we can return in facet the brand names, but aggregate the brand ids. This can be done by using FACET {expr1} BY {expr2}

MySQL [(none)]> SELECT * FROM facetdemo FACET brand_name by brand_id;
+------+-------+----------+---------------------+-------------+-------------+---------------------------------------+------------+
| id   | price | brand_id | title               | brand_name  | property    | j                                     | categories |
+------+-------+----------+---------------------+-------------+-------------+---------------------------------------+------------+
|    1 |   306 |        1 | Product Ten Three   | Brand One   | Six_Ten     | {"prop1":66,"prop2":91,"prop3":"One"} | 10,11      |
|    2 |   400 |       10 | Product Three One   | Brand Ten   | Four_Three  | {"prop1":69,"prop2":19,"prop3":"One"} | 13,14      |
....
|   19 |   855 |        1 | Product Seven Two   | Brand One   | Eight_Seven | {"prop1":63,"prop2":78,"prop3":"One"} | 10,11,12   |
|   20 |    31 |        9 | Product Four One    | Brand Nine  | Ten_Four    | {"prop1":79,"prop2":42,"prop3":"One"} | 12,13,14   |
+------+-------+----------+---------------------+-------------+-------------+---------------------------------------+------------+
20 rows in set (0.00 sec)
+-------------+----------+
| brand_name  | count(*) |
+-------------+----------+
| Brand One   |     1013 |
| Brand Ten   |      998 |
| Brand Five  |     1007 |
| Brand Nine  |      944 |
| Brand Two   |      990 |
| Brand Six   |     1039 |
| Brand Three |     1016 |
| Brand Four  |      994 |
| Brand Eight |     1033 |
| Brand Seven |      965 |
+-------------+----------+
10 rows in set (0.00 sec)

Facets can aggregate over multi-level grouping, the result set being the same as the query would perform a multi-level grouping:

MySQL [(none)]> select *,INTERVAL(price,200,400,600,800) as price_range from facetdemo facet price_range as fprice_range,brand_name order by brand_name asc;
+------+-------+----------+---------------------+-------------+-------------+---------------------------------------+------------+-------------+
| id   | price | brand_id | title               | brand_name  | property    | j                                     | categories | price_range |
+------+-------+----------+---------------------+-------------+-------------+---------------------------------------+------------+-------------+
|    1 |   306 |        1 | Product Ten Three   | Brand One   | Six_Ten     | {"prop1":66,"prop2":91,"prop3":"One"} | 10,11      |           1 |
...
+------+-------+----------+---------------------+-------------+-------------+---------------------------------------+------------+-------------+
20 rows in set (0.00 sec)

+--------------+-------------+----------+
| fprice_range | brand_name  | count(*) |
+--------------+-------------+----------+
|            1 | Brand Eight |      197 |
|            4 | Brand Eight |      235 |
|            3 | Brand Eight |      203 |
|            2 | Brand Eight |      201 |
|            0 | Brand Eight |      197 |
|            4 | Brand Five  |      230 |
|            2 | Brand Five  |      197 |
|            1 | Brand Five  |      204 |
|            3 | Brand Five  |      193 |
|            0 | Brand Five  |      183 |
|            1 | Brand Four  |      195 |
...

Facets support order clause as same as a standard query. In addition, special FACET() function can be used, which provides the aggregated data values.

MySQL [(none)]> select * from facetdemo facet brand_name by brand_id order by facet() asc facet brand_name by brand_id order by brand_name asc facet brand_name by brand_id order by count(*) desc;
+------+-------+----------+---------------------+-------------+-------------+---------------------------------------+------------+
| id   | price | brand_id | title               | brand_name  | property    | j                                     | categories |
+------+-------+----------+---------------------+-------------+-------------+---------------------------------------+------------+
|    1 |   306 |        1 | Product Ten Three   | Brand One   | Six_Ten     | {"prop1":66,"prop2":91,"prop3":"One"} | 10,11      |
...
|   20 |    31 |        9 | Product Four One    | Brand Nine  | Ten_Four    | {"prop1":79,"prop2":42,"prop3":"One"} | 12,13,14   |
+------+-------+----------+---------------------+-------------+-------------+---------------------------------------+------------+
20 rows in set (0.01 sec)

+-------------+----------+
| brand_name  | count(*) |
+-------------+----------+
| Brand One   |     1013 |
| Brand Two   |      990 |
| Brand Three |     1016 |
| Brand Four  |      994 |
| Brand Five  |     1007 |
| Brand Six   |     1039 |
| Brand Seven |      965 |
| Brand Eight |     1033 |
| Brand Nine  |      944 |
| Brand Ten   |      998 |
+-------------+----------+
10 rows in set (0.01 sec)

+-------------+----------+
| brand_name  | count(*) |
+-------------+----------+
| Brand Eight |     1033 |
| Brand Five  |     1007 |
| Brand Four  |      994 |
| Brand Nine  |      944 |
| Brand One   |     1013 |
| Brand Seven |      965 |
| Brand Six   |     1039 |
| Brand Ten   |      998 |
| Brand Three |     1016 |
| Brand Two   |      990 |
+-------------+----------+
10 rows in set (0.01 sec)

+-------------+----------+
| brand_name  | count(*) |
+-------------+----------+
| Brand Six   |     1039 |
| Brand Eight |     1033 |
| Brand Three |     1016 |
| Brand One   |     1013 |
| Brand Five  |     1007 |
| Brand Ten   |      998 |
| Brand Four  |      994 |
| Brand Two   |      990 |
| Brand Seven |      965 |
| Brand Nine  |      944 |
+-------------+----------+
10 rows in set (0.01 sec)

Returned result set¶

As it can be seen in the examples above, a faceted search will return a multiple result sets response. The MySQL client/library/connector used must have support (most do) for multiple result sets in order to be able to access the facet result sets.

By default, the facet result is not ordered and only the first 20 facet values are returned. The number of facet values can be controlled with LIMIT clause individually for each facet. The maximum facet values that can be returned is limited by the query’s max_matches setting. In case dynamic max_matches (limiting max_matches to offset+per page for better performance) is wanted to be implemented, it must be taken in account that a too low max_matches value can hurt the number of facet values. In this case, a minimum max_matches value should be used good enough to cover the number of facet values.

Performance¶

Internally, the FACET is a shorthand for executing a multi-query where the first query contains the main search query and the rest of the queries in the batch have each a clustering. As in the case of multi-query, the common query optimization can kick-in for a faceted search, meaning the search query is executed only once and the facets operates on the search query result, each facet adding only a fraction of time to the total query time.

To check if the faceted search ran in an optimized mode can be seen in query.log, where all the logged queries will contain a xN string, where N is the number of queries that ran in the optimized group or checking the output of SHOW META statement which will exhibit a multiplier metric:

MySQL [(none)]> select * from facetdemo facet brand_id facet price facet categories;show meta like 'multiplier';
+------+-------+----------+---------------------+-------------+-------------+---------------------------------------+------------+
| id   | price | brand_id | title               | brand_name  | property    | j                                     | categories |
+------+-------+----------+---------------------+-------------+-------------+---------------------------------------+------------+
|    1 |   306 |        1 | Product Ten Three   | Brand One   | Six_Ten     | {"prop1":66,"prop2":91,"prop3":"One"} | 10,11      |
...

+----------+----------+
| brand_id | count(*) |
+----------+----------+
|        1 |     1013 |
...

+-------+----------+
| price | count(*) |
+-------+----------+
|   306 |        7 |
...

+------------+----------+
| categories | count(*) |
+------------+----------+
|         10 |     2436 |
...

+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| multiplier    | 4     |
+---------------+-------+
1 row in set (0.00 sec)
Next Previous

© Copyright 2017-2020, Manticore Search team.

Built with Sphinx using a theme provided by Read the Docs.
Menu v: 3.2.0
latest
HTML
Single HTML
PDF
3.4.2
HTML
Single HTML
PDF
3.4.0
HTML
Single HTML
PDF
3.3.0
HTML
Single HTML
PDF
3.2.2
HTML
Single HTML
PDF
3.2.0
HTML
Single HTML
PDF
3.1.2
HTML
Single HTML
PDF
3.1.0
HTML
Single HTML
PDF
3.0.2
HTML
Single HTML
PDF
3.0.0
HTML
Single HTML
PDF
2.8.2
HTML
Single HTML
PDF
2.7.5
HTML
Single HTML
PDF
2.6.4
HTML
Single HTML
PDF
2.5.1
HTML
Single HTML
PDF
2.4.1
HTML
Single HTML
PDF
Links
Project Home
Github