हाय दोस्तों
मैं एक दिलचस्प तरकीब साझा करना चाहता हूँ कि कैसे आसानी से Sphinx / Manticore Search के लिए इंडेक्स किया जा सकता है बिना डेटाबेस में बहुत डेटा भरने की आवश्यकता के या ऐसा कुछ करने की। नीचे Sphinx / Manticore Search का पूर्ण कॉन्फ़िगरेशन है जो आपको 1 मिलियन डॉक्स इंडेक्स बनाने देता है जिसमें यादृच्छिक 3-अक्षर शब्द और भौगोलिक निर्देशांक हैं, इंडेक्स बनाने के लिए कमांड का उदाहरण और इंडेक्स में खोज करने वाले sphinxql क्वेरी का उदाहरण। आपको बस किसी भी डेटाबेस से कनेक्शन की आवश्यकता है (इस मामले में mysql -u root
काम करता है)।
[snikolaev@dev01 ~]$ cat sphinx_1m.conf
source min
{
type = mysql
sql_host = localhost
sql_user = root
sql_pass =
sql_db = test
sql_query_range = select 1, 1000000
sql_range_step = 1
sql_query = select $start, mid(md5(rand()), 1, 3) body, rand() * 180 lat, rand($end) * 90 lng
sql_attr_float = lat
sql_attr_float = lng
}
index idx
{
path = idx_1m
source = min
}
searchd
{
binlog_path = #
listen = 9314:mysql41
log = sphinx_1m.log
pid_file = sphinx_1m.pid
}
[snikolaev@dev01 ~]$ indexer -c sphinx_1m.conf --all --rotate
Manticore 2.6.1 9a706b4@180119 dev
Copyright (c) 2001-2016, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)
Copyright (c) 2017-2018, Manticore Software LTD (http://manticoresearch.com)
using config file 'sphinx_1m.conf'...
indexing index 'idx'...
WARNING: sql_range_step=1: too small; might hurt indexing performance!
collected 1000000 docs, 3.0 MB
sorted 1.0 Mhits, 100.0% done
total 1000000 docs, 3000000 bytes
total 86.580 sec, 34649 bytes/sec, 11549.98 docs/sec
total 5 reads, 0.014 sec, 4512.0 kb/call avg, 2.9 msec/call avg
total 24 writes, 0.031 sec, 1806.1 kb/call avg, 1.3 msec/call avg
rotating indices: successfully sent SIGHUP to searchd (pid=17284).
mysql> select id, geodist(lat,lng,73.9667,40.78, {in=deg,out=km}) dist, lat, lng from idx where dist < 5;
+--------+----------+-----------+-----------+
| id | dist | lat | lng |
+--------+----------+-----------+-----------+
| 636503 | 4.880664 | 73.952385 | 40.929459 |
+--------+----------+-----------+-----------+
1 row in set (0.09 sec)
जैसा कि आप देख सकते हैं, चतुर हिस्सा निर्देशों sql_query_range
और sql_range_step
का उपयोग करना है ताकि Manticore 1 मिलियन डॉक्स संग्रह बनाने तक लूप कर सके। नुकसान यह है कि वास्तविक डेटा को डेटाबेस से लाने की तुलना में इंडेक्सिंग धीमी है, लेकिन चलो, आप इसका उत्पादन में उपयोग नहीं करने वाले हैं, है ना?
मुझे उम्मीद है कि जब आप Manticore Search के साथ खेलने का निर्णय लेंगे तो यह आपको उपयोगी लगेगा।