इसमें जोड़ने के लिए कुछ full text searching
रेल के साथ विचार है। आप खोज करते हैं, तो आप के बारे में पता आप वास्तव में एक पूरा टेक्स्ट "खोज" अपने डीबी, जो एसक्यूएल इंजन के आधार पर अलग है में क्वेरी प्रदर्शन कर रहे हैं कि होने की जरूरत है आप
MYSQL पूर्ण पाठ का उपयोग खोज
LIKE %{search}%
तंत्र MYSQL की मूलभूत पूर्ण पाठ खोज सुविधा है, और मूल रूप से आपके डीबी में पूरे रिकॉर्ड के अंदर आपकी लक्षित क्वेरी को देखता है। इसका मतलब यह है कि अगर आपकी क्वेरी है इस:
SELECT * FROM `products` WHERE `name` LIKE '%alligator%'
MYSQL मूल रूप से आपकी क्वेरी के लिए किसी भी संदर्भ के लिए पूरे "नाम" रिकॉर्ड के माध्यम से दिखेगा। परिणाम इस बात पर आधारित होंगे कि आपके रिकॉर्ड में "एलीगेटर" शब्द किसी भी हिस्से में है या नहीं। This reference के बारे में इस
PostgreSQL पूर्ण पाठ खोज
कारण मैंने लिखा क्योंकि psql वास्तव में अलग ढंग से करता है, और इसलिए क्वेरी आप प्रदान किया गया है केवल MySQL के लिए काम करेंगे इस पोस्ट है कुछ और बताते हैं ।Psql विभिन्न कार्यों पूरा टेक्स्ट खोज संभाल करने का एक बहुत कुछ है, लेकिन क्योंकि हम Heroku उपयोग करें, हम Textacular gem उपयोग करने के लिए ठीक से
यहाँ some ways PSQL handles full text searching काम कर यह सब पाने में कामयाब रहे:
Full text searching in PostgreSQL is based on the match operator @@, which returns true if a tsvector (document) matches a tsquery (query). It doesn't matter which data type is written first:
SELECT 'a fat cat sat on a mat and ate a fat rat'::tsvector @@ 'cat &
rat'::tsquery; ?column?
---------- t
SELECT 'fat & cow'::tsquery @@ 'a fat cat sat on a mat and ate a fat
rat'::tsvector; ?column?
---------- f
As the above example suggests, a tsquery is not just raw text, any more than a tsvector > is. A tsquery contains search terms, which must be already-normalized lexemes, and may combine multiple terms using AND, OR, and NOT operators. (For details see Section 8.11.) There are functions to_tsquery and plainto_tsquery that are helpful in converting user-written text into a proper tsquery, for example by normalizing words appearing in the text. Similarly, to_tsvector is used to parse and normalize a document string. So in practice a text search match would look more like this:
SELECT to_tsvector('fat cats ate fat rats') @@ to_tsquery('fat & rat'); ?column?
---------- t Observe that this match would not succeed if written as
SELECT 'fat cats ate fat rats'::tsvector @@ to_tsquery('fat & rat'); ?column? ---------- f
पूर्ण पाठ खोज सॉफ्टवेयर
पूर्ण पाठ खोज डीबी पर स्वाभाविक रूप से काफी महंगा है, खासकर अगर आपके पास खोज करने के लिए बहुत सारे डेटा हैं। यही कारण है कि sunspot solr या sphinx तरह समाधान मौजूद है - खोज डेटा से अपने आप दोनों सूचकांक & के लिए एक रास्ता प्रदान करने के लिए
आपके आवेदन काफी लोकप्रिय हो जाता है, तो आप इस तरह के रूप पूर्ण पाठ खोज प्रणालियों में से एक में निवेश करने के लिए, इच्छा हो सकती है these demonstrated by Heroku:
आप खोज कीवर्ड मिलान बिल्कुल प्रोफ़ाइल विषय की आवश्यकता है? – Teddy
बिलकुल ठीक नहीं है, अगर विषय के नाम से शब्द मिलान पर विषय नाम खोज परिणामों में प्रदर्शित होना चाहिए। – Murtza