Sphinx Server Configuration

Source: Internet
Author: User

This example does not support Chinese search currently.

Download mysql5.0.27 and above http://dev.mysql.com


Download sphinx-0.9.8-win32.zip and mysql-5.0.45-sphinxse-0.9.8-from the official sphinx website http://www.sphinxsearch.com/downloads.html-

Win32.zip

Stop MySQL and decompress mysql-5.0.45-sphinxse-0.9.8-win32.zip. Overwrite bin and share in the MySQL directory.

Decompress sphinx-0.9.8-win32.zip to an independent directory, for example, D:/www/sphinx /.

Create a test table in the Test Database

Create Table 'documents '(
'Id' int (11) not null auto_increment,
'Group _ id' int (11) not null,
'Group _ id2' int (11) not null,
'Date _ added' datetime not null,
'Title' varchar (255) not null,
'Content' text not null,
Primary Key ('id ')
) Engine = InnoDB auto_increment = 5;

Insert into 'documents' values ('1', '1', '5', '2017-09-13 21:37:47 ', 'test one', 'This is my test document number

One. Also checking search within phrases .');
Insert into 'documents' values ('2', '1', '6', '2017-09-13 21:37:47 ', 'test two', 'This is my test document number

Two ');
Insert into 'documents' values ('3', '2', '7', '2017-09-13 21:37:47 ', 'Another doc ', 'This is another group ');
Insert into 'documents' values ('4', '2', '8', '2017-09-13 21:37:47 ', 'doc Number Four ', 'This is to test groups ');


Configure sphinx-doc.conf files
Rename a copy of The sphinx-min.conf under sphinx to a sphinx-doc.conf

#
# Minimal sphinx configuration sample (clean, simple, functional)
#
Source documents
{
Type = MySQL
SQL _host = localhost
SQL _user = test
SQL _pass = test
SQL _db = test
SQL _port = 3306 # optional, default is 3306

SQL _query = \
Select ID, group_id, unix_timestamp (date_added) as date_added, title, content \
From documents

SQL _attr_uint = group_id
SQL _attr_timestamp = date_added

SQL _query_info = select * from documents where id = $ ID
}


Index documents
{
Source = documents
Path = D:/www/sphinx/data/doc

Morphology = extern
Enable_star = 1

Min_word_len = 3
Min_prefix_len = 0
Min_infix_len = 3


}
Indexer
{
Mem_limit = 32 m
}
Searchd
{
Port = 3312
Log = D:/www/sphinx/data/log/searchd-doc.log
Query_log = D:/www/sphinx/data/log/query-doc.log
Read_timeout = 5
Max_children = 30
Pid_file = D:/www/sphinx/data/log/searchd-doc.pid
Max_matches = 1000
Seamless_rotate = 0
Preopen_indexes = 0
Unlink_old = 1
}

Start MySQL Database Net start MySQL


Generate data index or recreate Index

D:/www/sphents/bin/indexer.exe -- config D:/www/sphents/bin/sphinx-doc.conf documents

Run search daemon searchd.exe

D:/www/sphinx/bin/searchd.exe -- config D:/www/sphinx/bin/sphinx-doc.conf

In this case, Sphinx is running normally. You can use netstat-An to check whether port 3312 is in the listening status.


Now we use the sphinxtool search.exe to test the same thing.


Index Keyword: This is m

D: \ www \ sphinx \ bin> search.exe-c d:/www/sphinx/bin/sphinx-doc.conf this is m
Sph00000.9.8-release (r1371)
Copyright (c) 2001-2008, Andrew aksyonoff

Using config file 'd:/www/sphinx/bin/sphinx-doc.conf '...
Warning: Index 'documents': Invalid morphology option 'pattern'-ignored
Index 'documents': query'this is m': returned 4 matches of 4 Total in 0.000 s
C

Displaying matches:
1. Document = 1, Weight = 1, group_id = 1, date_added = SAT Sep 13 21:37:47 2008
Id = 1
Group_id = 1
Group_id2 = 5
Date_added = 2008-09-13 21:37:47
Title = test one
Content = This is my test document number one. Also checking search withi
Phrases.
2. Document = 2, Weight = 1, group_id = 1, date_added = SAT Sep 13 21:37:47 2008
Id = 2
Group_id = 1
Group_id2 = 6
Date_added = 2008-09-13 21:37:47
Title = test two
Content = This is my test document number two
3. Document = 3, Weight = 1, group_id = 2, date_added = SAT Sep 13 21:37:47 2008
Id = 3
Group_id = 2
Group_id2 = 7
Date_added = 2008-09-13 21:37:47
Title = another doc
Content = This is another group
4. Document = 4, Weight = 1, group_id = 2, date_added = SAT Sep 13 21:37:47 2008
Id = 4
Group_id = 2
Group_id2 = 8
Date_added = 2008-09-13 21:37:47
Title = Doc number four
Content = This is to test groups

Words:
1. 'eas': 4 documents, 4 hits

Index Keyword: This is another group
D: \ www \ sphinx \ bin> search.exe-c d:/www/sphinx/bin/sphinx-doc.conf this is another group
Sph00000.9.8-release (r1371)
Copyright (c) 2001-2008, Andrew aksyonoff

Using config file 'd:/www/sphinx/bin/sphinx-doc.conf '...
Warning: Index 'documents': Invalid morphology option 'pattern'-ignored
Index 'documents': query'this is another group ': returned 1 matches of 1 Total
In 0.000 Sec

Displaying matches:
1. Document = 3, Weight = 4, group_id = 2, date_added = SAT Sep 13 21:37:47 2008
Id = 3
Group_id = 2
Group_id2 = 7
Date_added = 2008-09-13 21:37:47
Title = another doc
Content = This is another group

Words:
1. 'eas': 4 documents, 4 hits
2. 'Another ': 1 Documents, 2 hits
3. 'group': 1 users, 1 hits

To this Sphinx in win is normal operation, sphinx-doc.conf file configuration is more flexible, according to your need to index the database for flexible configuration to achieve your needs Effect

If the running parameter configuration problem occurs during the configuration process, you can view the DOC/sphinx.html file, which provides detailed descriptions of various parameters.

 

References:

Http://www.sphinxsearch.com/wiki/doku.php? Id = sphinx_chinese_tutorial

Http://www.ibm.com/developerworks/cn/opensource/os-php-sphinxsearch/

Http://dev.cgfinal.com/sphinx/sphinx.html

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.