Manticore Search के साथ खेलने के लिए न्यूनतम कॉन्फ़िगरेशन

यदि आप Manticore Search के साधारण इंडेक्स को सीखना शुरू करना चाहते हैं या इसके कुछ फ़ीचर्स कैसे काम करते हैं, तो निम्नलिखित सबसे सरल Manticoresearch कॉन्फ़िगरेशन उपयोगी हो सकता है:

source min {
    type = mysql
    sql_host = localhost
    sql_user = root
    sql_pass =
    sql_db = test
    sql_query = select 1, 'cat' union select 2, 'dog'
}
index idx_min {
    path = idx
    source = min
}
searchd {
    listen = 9306:mysql41
    log = searchd.log
    pid_file = manticoresearch.pid
    binlog_path =
}

यह लगभग कुछ नहीं है, बल्कि केवल वही चीजें हैं जिनके बिना Manticoresearch काम नहीं कर सकता। वे हैं:

  • सेक्शन “source” mysql से डेटा लाने के लिए। इस मामले में, हम mysql से असली डेटा नहीं लाते हैं, बल्कि कॉन्फ़िग में सीधे डेटा को परिभाषित करते हुए mysql इंटरफेस का उपयोग करते हैं (“select 1, ‘cat’ union select 2, ‘dog’")। यह Manticoresearch में 2 दस्तावेज़ बनाएगा: एक “cat” शब्द वाला और दूसरा “dog” शब्द वाला, IDs क्रमशः 1 और 2 हैं।

  • सेक्शन “index” ऊपर दिए गए स्रोत आधारित इंडेक्स बनाने के लिए, जिसमें केवल स्रोत का संदर्भ (“source = min”) और इंडेक्स के लिए पथ (“path = idx”) होता है। एक बार जब आप इस इंडेक्स को बनाते हैं, तो idx.* फ़ाइलें उस डायरेक्टरी में बनाई जाएंगी जहाँ से आप ‘indexer’ शुरू करते हैं।

  • सेक्शन “searchd” Manticoresearch को बताने के लिए कि उसे किस पोर्ट पर सुनना चाहिए (“listen = 9306:mysql41”, जिसका अर्थ है कि इस पोर्ट पर Manticoresearch से बात करने के लिए SphinxQL का उपयोग किया जाना चाहिए), उसे कौन सा लॉग उपयोग करना चाहिए (“log = searchd.log”) और उसे अपनी प्रक्रिया ID कहाँ सहेजनी चाहिए (“pid_file = manticoresearch.pid”)।

यहाँ इस कॉन्फ़िग का उपयोग करने का एक उदाहरण है:

इंडेक्सिंग:


[snikolaev@dev01 ~]$ indexer -c min.conf --all
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 'min.conf'...
indexing index 'idx_min'...
WARNING: Attribute count is 0: switching to none docinfo
collected 2 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 2 docs, 6 bytes
total 0.045 sec, 131 bytes/sec, 43.75 docs/sec
total 3 reads, 0.000 sec, 10.6 kb/call avg, 0.0 msec/call avg
total 9 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg

‘searchd’ शुरू करना और mysql क्लाइंट का उपयोग करके परिणाम लाना:


[snikolaev@dev01 ~]$ searchd -c min.conf
Manticore 2.6.2 df9dc57@180213 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 'min.conf'...
listening on all interfaces, port=9306
precaching index 'idx_min'
precached 1 indexes in 0.001 sec

[snikolaev@dev01 ~]$ mysql -P9306 -h0
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 2.6.2 df9dc57@180213 dev

Copyright (c) 2009-2017 Percona LLC and/or its affiliates
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select * from idx_min where match('dog');
+------+
| id |
+------+
| 2 |
+------+
1 row in set (0.00 sec)

mysql> select * from idx_min where match('cat');
+------+
| id |
+------+
| 1 |
+------+
1 row in set (0.00 sec)

जब searchd चल रहा हो, यदि आप इंडेक्स को पुनर्निर्माण करना चाहते हैं, तो आप इसे searchd को बंद किए बिना कर सकते हैं यदि आप indexer –rotate चलाते हैं:


[snikolaev@dev01 ~]$ indexer -c min.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 'min.conf'...
indexing index 'idx_min'...
WARNING: Attribute count is 0: switching to none docinfo
collected 2 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 2 docs, 6 bytes
total 0.003 sec, 1547 bytes/sec, 515.86 docs/sec
total 3 reads, 0.000 sec, 10.6 kb/call avg, 0.0 msec/call avg
total 9 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
rotating indices: successfully sent SIGHUP to searchd (pid=27004).

जैसा कि आप अंतिम पंक्ति में देख सकते हैं, indexer ने searchd को संकेत भेजा ताकि वह इंडेक्स को घुमाए।

Manticore Search के साथ खेलने का आनंद लें!

मैंटीकोर सर्च इंस्टॉल करें

मैंटीकोर सर्च इंस्टॉल करें