Mysql
 sql >> डेटाबेस >  >> RDS >> Mysql

लागू करने के लिए सबसे आसान साइट खोज एप्लिकेशन क्या है, जो फजी खोज का समर्थन करता है?

इवेमली का उत्तर सही दिशा में है, लेकिन आपको फुलटेक्स्ट और साउंडएक्स मैपिंग का संयोजन करना चाहिए, फुलटेक्स्ट को प्रतिस्थापित नहीं करना चाहिए, अन्यथा आपकी पसंद की क्वेरी बहुत धीमी हो सकती हैं।

create table with_soundex (
  id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
  original TEXT,
  soundex TEXT,
  FULLTEXT (soundex)
);

insert into with_soundex (original, soundex) values 

('add some test cases', CONCAT_WS(' ', soundex('add'), soundex('some'), soundex('test'), soundex('cases'))),
('this is some text', CONCAT_WS(' ', soundex('this'), soundex('is'), soundex('some'), soundex('text'))),
('one more test case', CONCAT_WS(' ', soundex('one'), soundex('more'), soundex('test'), soundex('case'))),
('just filling the index', CONCAT_WS(' ', soundex('just'), soundex('filling'), soundex('the'), soundex('index'))),
('need one more example', CONCAT_WS(' ', soundex('need'), soundex('one'), soundex('more'), soundex('example'))),
('seems to need more', CONCAT_WS(' ', soundex('seems'), soundex('to'), soundex('need'), soundex('more')))
('some helpful cases to consider', CONCAT_WS(' ', soundex('some'), soundex('helpful'), soundex('cases'), soundex('to'), soundex('consider')))

select * from with_soundex where match(soundex) against (soundex('test'));
+----+---------------------+---------------------+
| id | original            | soundex             |
+----+---------------------+---------------------+
|  1 | add some test cases | A300 S500 T230 C000 | 
|  2 | this is some text   | T200 I200 S500 T230 | 
|  3 | one more test case  | O500 M600 T230 C000 | 
+----+---------------------+---------------------+

select * from with_soundex where match(soundex) against (CONCAT_WS(' ', soundex('test'), soundex('some')));
+----+--------------------------------+---------------------------+
| id | original                       | soundex                   |
+----+--------------------------------+---------------------------+
|  1 | add some test cases            | A300 S500 T230 C000       | 
|  2 | this is some text              | T200 I200 S500 T230       | 
|  3 | one more test case             | O500 M600 T230 C000       | 
|  7 | some helpful cases to consider | S500 H414 C000 T000 C5236 | 
+----+--------------------------------+---------------------------+

यह बहुत अच्छे परिणाम देता है (साउंडेक्स एल्गो की सीमा के भीतर) एक इंडेक्स का अधिकतम लाभ लेते हुए (किसी भी क्वेरी LIKE '%foo' को टेबल की हर पंक्ति को स्कैन करना होता है)।

प्रत्येक शब्द पर ध्वनि चलाने के महत्व पर ध्यान दें, पूरे वाक्यांश पर नहीं। आप एसक्यूएल करने के बजाय प्रत्येक शब्द पर साउंडएक्स का अपना संस्करण भी चला सकते हैं, लेकिन उस स्थिति में सुनिश्चित करें कि एल्गोरिदम के बीच अंतर होने पर भंडारण और पुनर्प्राप्त करते समय आप इसे दोनों करते हैं (उदाहरण के लिए, MySQL का एल्गो सीमित नहीं है खुद को मानक 4 chars के अनुसार )



  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. पिवट फ़ंक्शन या यूनियन का उपयोग किए बिना तालिका को पिवट करने के लिए MySQL कथन

  2. MySQL में XPATH का चयन कैसे करें?

  3. डेटाबेस नामों की जाँच करना और रन टाइम पर डेटाबेस बनाना

  4. MySQLdb के माध्यम से फ़ंक्शन बनाएं

  5. NullPointerException - डेटाबेस से डेटा पुनर्प्राप्त करते समय और एक सरणी में संग्रहीत करते समय डेटाबेस लॉक समस्या