ArticleslgStudy

computer science

Sphinx (search engine)

Sphinx (search engine) is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Sphinx (search engine) rather than just read about it. In short: Sphinx is a fulltext search engine that provides text search functionality to client applications. Overview Sphinx can be used either as a stand-alone server or as a storage engine ("SphinxSE") for the MySQL family of databases.

Sphinx (search engine) — main illustration
Sphinx (search engine) — illustration

Key takeaways

  • Sphinx (search engine) belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Sphinx (search engine) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Sphinx (search engine) from memory before moving on to harder problems.

Reference excerpt

Sphinx is a fulltext search engine that provides text search functionality to client applications.

Overview Sphinx can be used either as a stand-alone server or as a storage engine ("SphinxSE") for the MySQL family of databases. When run as a stand-alone server, Sphinx operates like a DBMS and can communicate with MySQL, MariaDB, and PostgreSQL through their native protocols or with any ODBC-compliant DBMS via ODBC. MariaDB, a fork of MySQL, is distributed with SphinxSE.

SphinxAPI If Sphinx is run 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 a 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 and/or clients. Sphinx supports a subset of SQL known as 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 MySQL and MariaDB to communicate with Sphinx's searchd to run queries and obtain results. Sphinx indices are treated like regular SQL tables. The SphinxSE storage engine is shipped with MariaDB.

Full-text fields and indexing Sphinx is configured to examine a data set via its Indexer. The Indexer process creates a full-text index (a special data structure that enables quick keyword searches) from the given data/text. Full-text fields are the resulting content that is indexed by Sphinx; they 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 data is not stored in the Sphinx index, but are discarded during the Indexing process; Sphinx assumes that you store those contents elsewhere.

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:

unsigned integers (1-bit to 32-bit wide); UNIX timestamps; floating point values (32-bit, IEEE 754 single precision); string ordinals (specially computed integers); strings (since 1.10-beta);

JSON (since 2.1.1-beta);

MVA, multi-value attributes (variable-length lists of 32-bit unsigned integers).

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: mapping sparse data to static columns can be 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 Up until version 3, Sphinx is dual licensed; either:

GNU General Public License version 2 or proprietary licensing is available for use-cases which are not within the terms of the GNU GPLv2. Since version 3, Sphinx has become proprietary, with a promise to release its source code in the future

Sphinx use examples Craigslist.org Tradebit.com vBulletin.com MediaWiki extension Boardreader.com OMBE.com Limundo.com

Feature list Batch and incremental (soft real-time) full-text indexing. Support for non-text attributes (scalars, strings, sets, JSON). Direct indexing of SQL databases. Native support for MySQL, MariaDB, PostgreSQL, MSSQL, plus ODBC connectivity. XML document indexing support. Distributed searching support out-of-the-box. Integration via access APIs. SQL-like syntax support via MySQL protocol (since 0.9.9) Full-text searching syntax. Database-like result set processing. Relevance ranking utilizing additional factors besides standard BM25. Text processing support for SBCS and UTF-8 encodings, stopwords, indexing of words known not to appear in the database ("hitless"), stemming, word forms, tokenizing exceptions, and "blended characters" (dual-indexing as both a real character and a word separator). Supports UDF (since 2.0.1).

Performance and scalability Indexing speed of up to 10-15 MB/sec per core and HDD. Searching speed of over 500 queries/sec against 1,000,000 document/1.2 GB collection using a 2-core desktop system with 2 GB of RAM. The biggest known installation using Sphinx, Boardreader.com, indexes 16 billion documents. The busiest known installation, Craigslist, serves over 300,000,000 queries/day and more than 50 billion page views/month.

Fork In 2017, key members of the original Sphinx team forked the project under the name Manticore, with the intention of fixing bugs and developing new features. Unlike Sphinx, Manticore continues to be released as open source under version 3 of the GPL.

See also

List of information retrieval libraries

References

Further reading Aksyonoff, Andrew (2011). Introduction to Search with Sphinx: From installation to relevance tuning. O'Reilly Media. ISBN 978-0-596-80955-3. Ali, Abbas (2011). Sphinx Search Beginner's Guide. Birmingham, England: Packt Publishing. ISBN 978-1-84951-254-1. No more open-source (2017) https://sphinxsearch.com/blog/2017/07/24/sphinx-2017/

External links

Official website SphinxSE in MariaDB KnowledgeBase https://manticoresearch.com/ - Manticore opensource fork site.

Worked examples

Example 1 — a first encounter with Sphinx (search engine)

Start with the simplest possible case. Write down what Sphinx (search engine) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Sphinx (search engine) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Sphinx (search engine) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Sphinx (search engine)

In research
Sphinx (search engine) appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Sphinx (search engine) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Sphinx (search engine) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Free search engine software, so understanding it makes those chapters shorter.
In everyday life
Look for Sphinx (search engine) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Sphinx (search engine)” →

How to study Sphinx (search engine) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Sphinx (search engine) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Sphinx (search engine) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Sphinx (search engine) in simple terms?

Sphinx is a fulltext search engine that provides text search functionality to client applications. Overview Sphinx can be used either as a stand-alone server or as a storage engine ("SphinxSE") for the MySQL family of databases.

Why does Sphinx (search engine) matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Sphinx (search engine)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Sphinx (search engine).

Tags

  • Free search engine software

Keep exploring