[In layman Sphinx] Sphinx Configuration File Parsing

Source: Internet
Author: User

The above describes the work of Sphinx, about how to install the article in the online there are many, the author will not repeat, and now continue to explain Sphinx configuration files, let Sphinx work up.

Data Source Configuration

Let's take a look at a sample configuration file for a data source:

1 Source Test2  {3Type =MySQL4  5Sql_host =127.0.0.16Sql_user =Root7Sql_pass =Root8sql_db =Test9Sql_port =3306# optional, default is3306Ten   OneSql_query_pre =SET NAMES UTF8 ASql_query = SELECTID,name, add_time from Tbl_test -   -Sql_attr_timestamp =Add_time the   -Sql_query_info_pre =SET NAMES UTF8 -Sql_query_info = SELECT * from Tbl_test WHEREID=$ID -}

which

Source is followed by the name of the data source, the subsequent indexing will be used;

Type: Data source types, can be mysql,postresql,oracle and so on;

Sql_host, Sql_user, Sql_pass, sql_db, Sql_port are the authentication information of the connection database;

Sql_query_pre: Encoding when defining a query

Sql_query: Data Source Configuration Core statement, Sphinx Use this statement to pull data from the database;

Sql_attr_*: Indexed Properties, additional information (values) attached to each document, can be used for filtering and sorting when searching. Once the property is set, when the Sphinx Search API is called, Sphinx returns the properties that have been set;

Sql_query_info_pre: Set the query encoding, if the question mark in the command line debugging appears garbled, you can set this;

Sql_query_info: Sets the information returned under the command line.

Index configuration
1 Index Test_index2 {3Source =Test4Path =/usr/local/coreseek/var/data/test
5DocInfo =extern6Charset_dictpath =/usr/local/mmseg3/etc/7Charset_type = zh_cn.utf-88Ngram_len =19Ngram_chars = u+ the.. u+2fa1fTen}

which

The Test_index followed by index is the indexed name

Source: Data source name;

Path: Index file base name, the indexer program generates the index file name as a prefix. For example, an attribute assembly exists in/usr/local/sphinx/data/test1.spa, and so on.

DocInfo: Indexed document property value storage mode;

Charset_dictpath: Chinese word segmentation when the dictionary file is enabled directory, the directory must have uni.lib dictionary file exists;

Charset_type: Data encoding type;

Ngram_len: participle length;

Ngram_chars: A valid character set to be recognized by the unary-segmentation sub-mode.

Chinese Word segmentation core configuration unary participle
1 charset_type = UTF823145 ngram_chars = u+3000 .. u+2fa1f
Mmseg participle
1 charset_type = UTF823 charset_dictpath =/usr/local/mmseg3/etc/45  0
Run the sample

Database data

Indexing using the indexer program

Inquire

As you can see, the add_time in the configuration file is returned, as shown in 1. The information returned by Sql_query_info is shown in 2.

Conclusion

The configuration of the Sphinx is not very flexible, and the configuration of each part is given here according to the workflow above, and more advanced configurations can be consulted when using the document.

Original article, writing Limited, Caishuxueqian, if there is not in the text, million hope to inform.

If this article is helpful to you, please click on the recommendation, write the article is not easy.

[In layman Sphinx] Sphinx Configuration File Parsing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.