Developer(s) Andrew Aksyonoff Written in C++ | Development status Active | |
Initial release 2001; 16 years ago (2001) Stable release 2.2.11 / 26 July 2016; 7 months ago (2016-07-26) Preview release 2.3.2-beta / 8 September 2016; 6 months ago (2016-09-08) |
Sphinx is a free software/open source fulltext search engine designed to provide text search functionality to client applications.
Contents
Overview
Like other DBMS's, Sphinx can be used as a stand-alone server. It can be used to communicate with other DBMS's by using native protocols of MySQL, MariaDB and PostgreSQL, or by using ODBC with ODBC-compliant DBMS's. And, Sphinx can also be used as a storage engine ("SphinxSE") for MySQL and its forks. MariaDB, a fork of MySQL, is distributed with SphinxSE.
SphinxAPI
If Sphinx is executed as a stand-alone server, it is possible to use SphinxAPI to connect an application to it. Official implementations of the API are available for PHP, Java, Perl, Ruby and Python languages. Unofficial implementations for other languages, as well as various third party plugins and modules are also available. Other data sources can be indexed via pipe in a custom XML format.
SphinxQL
The Sphinx search daemon supports the MySQL binary network protocol and can be accessed with the regular MySQL API. Sphinx also supports a subset of SQL (SphinxQL). It supports standard querying of all index types with SELECT, modifying RealTime indexes with INSERT, REPLACE, and DELETE, and more.
SphinxSE
Sphinx can also provide a special storage engine for MariaDB and MySQL databases. This allows those MySQL, MariaDB to communicate with Sphinx's searchd
to run queries and obtain results. Sphinx indices are treated like regular SQL tables.
Full-text fields
Full-text fields (or just fields for brevity) are the textual document contents that get indexed by Sphinx, and can be (quickly) searched for keywords. Fields are named, and you can limit your searches to a single field (e.g. search through "title" only) or a subset of fields (e.g. to "title" and "abstract" only). Sphinx's index format generally supports up to 256 fields. Note that the original contents of the fields are not stored in the Sphinx index. The text that you send to Sphinx gets processed, and a full-text index (a special data structure that enables quick searches for a keyword) gets built from that text. But the original text contents are then simply discarded. Sphinx assumes that you store those contents elsewhere anyway.
Attributes
Attributes are additional values associated with each document that can be used to perform additional filtering and sorting during search. Attributes are named. Attribute names are case insensitive. Attributes are not full-text indexed; they are stored in the index as is. Currently supported attribute types are:
More about JSON Attributes in Sphinx
Sphinx, like classic SQL databases, works with a so-called fixed schema, that is, a set of predefined attribute columns. These work well when most of the data stored actually has values. However, mapping sparse data to static columns can be very cumbersome. Assume for example that you’re running a price comparison or an auction site with many different products categories. Some of the attributes like the price or the vendor are identical across all goods. But from there, for laptops, you also need to store the weight, screen size, HDD type, RAM size, etc. And, say, for shovels, you probably want to store the color, the handle length, and so on. So it’s manageable across a single category, but all the distinct fields that you need for all the goods across all the categories are legion. The JSON field can be used to overcome this. Inside the JSON attribute you don’t need a fixed structure. You can have various keys which may or may not be present in all documents. When you try to filter on one of these keys, Sphinx will ignore documents that don’t have the key in the JSON attribute and will work only with those documents that have it.
License
Sphinx is dual licensed:
- GNU General Public License version 2
- and, commercial licensing is available for use-cases which are not within the terms of the GNU GPLv2.