[Sphtracing] sphtracing configuration file parsing,

Source: Internet
Author: User

[Sphtracing] sphtracing configuration file parsing,

I have introduced the working principle of Sphinx above. There are many articles on how to install Sphinx on the Internet, so I will not repeat it again. Now I will continue to explain the Sphinx configuration file to let Sphinx work.

Data source configuration

Let's take a look at the sample configuration file of a Data source:

 1 source test 2  { 3      type                    = mysql 4   5      sql_host                = 127.0.0.1 6      sql_user                = root 7      sql_pass                = root 8      sql_db                  = test 9      sql_port                = 3306    # optional, default is 330610  11      sql_query_pre           = SET NAMES utf812      sql_query            = SELECT id, name, add_time FROM tbl_test13  14      sql_attr_timestamp      = add_time15  16    sql_query_info_pre      = SET NAMES utf817      sql_query_info          = SELECT * FROM tbl_test WHERE id=$id18  }

 

Where

The source is followed by the name of the data source, which will be used for indexing later;

Type: data source type, which can be MySQL, PostreSQL, Oracle, etc;

SQL _host, SQL _user, SQL _pass, SQL _db, and SQL _port are the authentication information for connecting to the database;

SQL _query_pre: defines the encoding for the query.

SQL _query: the Core Statement for configuring the data source. sphinx uses this statement to pull data from the database;

SQL _attr _ *: index attribute, additional information (values) appended to each document, which can be used for filtering and sorting during search. After attributes are set, when you call the Sphinx API to search for an API, Sphinx returns the configured attributes;

SQL _query_info_pre: sets the query encoding. If the question mark is garbled during Command Line Debugging, you can set this item;

SQL _query_info: Set the information returned under the command line.

Index Configuration
 1 index test_index 2 { 3     source                    = test 4     path                      = /usr/local/coreseek/var/data/test
5 docinfo = extern 6 charset_dictpath = /usr/local/mmseg3/etc/ 7 charset_type = zh_cn.utf-8 8 ngram_len = 1 9 ngram_chars = U+3000..U+2FA1F 10 }

Where

The test_index followed by the index is the index name.

Source: Data source Name;

Path: Basic name of the index file. The indexer program uses this path as the prefix to generate the index file name. For example, a property Assembly exists in/usr/local/sphinx/data/test1.spa.

Docinfo: storage mode for index document attribute values;

Charset_dictpath: Specifies the directory where dictionary files are enabled for Chinese word segmentation. A uni. lib dictionary file must exist in this directory;

Charset_type: data encoding type;

Ngram_len: Word Segmentation length;

Ngram_chars: a valid character set to be recognized in the unidimensional character splitting mode.

Chinese Word Segmentation core configuration mona1 Word Segmentation
1 charset_type = utf82 3 ngram_len = 14 5 ngram_chars = U+3000..U+2FA1F
Mmseg Word Segmentation
1 charset_type = utf82 3 charset_dictpath = /usr/local/mmseg3/etc/4 5 ngram_len = 0
Running example

Database Data

 

Use the indexer program for Indexing

 

Query

As you can see, 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 Sphinx is not flexible. The configuration of each part is provided based on the previous workflow. For more advanced configurations, refer to the documentation.

 

The original article is limited in writing, so it is easy to learn. If there is anything wrong with the article, please let us know.

If this article is helpful to you, click here for recommendations. It is not easy to write articles.

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.