2013-01-04 10 views
7

मैं निम्नलिखित कमांड का उपयोग करके मोंगोडब-नदी का उपयोग करके लोचदार खोज में मोंगोडब को इंडेक्स करने की कोशिश कर रहा हूं लेकिन दस्तावेज़ मैपिंग प्रभावी नहीं हो रहा है। यह अभी भी क्षेत्र textमैंगोडब नदी के माध्यम से लोचदार खोज में इंडेक्स बनाने में मैपिंग प्रभाव नहीं ले रहा है

Mongodb-river दस्तावेज़ सूचकांक के निर्माण को निर्दिष्ट करता है लेकिन वहाँ कैसे कस्टम मैपिंग प्रदान करने के लिए पर कोई प्रलेखन है के लिए डिफ़ॉल्ट विश्लेषक (मानक) का उपयोग कर रहा है। मैंने यही कोशिश की। क्या कोई अन्य दस्तावेज है जहां मैं मोंगोद-नदी का उपयोग करने में कस्टम विश्लेषक आदि निर्दिष्ट करने के तरीके को पा सकता हूं।

curl -XPUT "localhost:9200/_river/autocompleteindex/_meta" -d ' 
{ 
    "type": "mongodb", 
    "mongodb": { 
     "host": "rahulg-dc", 
     "port": "27017", 
     "db": "qna", 
     "collection": "autocomplete_questions" 
    }, 
    "index": { 
     "name": "autocompleteindex", 
     "type": "autocomplete_questions", 
     "analysis" : { 
       "analyzer" : { 
        "str_search_analyzer" : { 
          "tokenizer" : "keyword", 
          "filter" : ["lowercase"] 
         }, 

         "str_index_analyzer" : { 
         "tokenizer" : "keyword", 
         "filter" : ["lowercase", "ngram"] 
        } 
       }, 
       "filter" : { 
        "ngram" : { 
         "type" : "ngram", 
         "min_gram" : 2, 
         "max_gram" : 20 
        } 
       } 
      } 
    }, 
    "autocompleteindex": { 
     "_boost" : { 
      "name" : "po", 
      "null_value" : 1.0 
     }, 
     "properties": { 
       "po": { 
        "type": "double" 
       }, 
       "text": { 
        "type": "string", 
        "boost": 3.0, 
        "search_analyzer" : "str_search_analyzer", 
        "index_analyzer" : "str_index_analyzer" 
       }   
     } 
    } 
}' 

क्वेरी उचित परिणाम देता है मैं पूर्ण शब्दों से खोजता हूं लेकिन किसी भी सबस्ट्रिंग मैच से मेल नहीं खाता है। इसके अलावा, बढ़ावा कारक इसका प्रभाव नहीं दिखा रहा है।

मैं क्या गलत कर रहा हूं ??

उत्तर

8

आप अपने index settings (विश्लेषक) के साथ पहली बार अपने सूचकांक बनाने के लिए:

"analysis" : { 
      "analyzer" : { 
       "str_search_analyzer" : { 
         "tokenizer" : "keyword", 
         "filter" : ["lowercase"] 
        }, 

        "str_index_analyzer" : { 
        "tokenizer" : "keyword", 
        "filter" : ["lowercase", "ngram"] 
       } 
      }, 
      "filter" : { 
       "ngram" : { 
        "type" : "ngram", 
        "min_gram" : 2, 
        "max_gram" : 20 
       } 
      } 
     } 

तो फिर आप अपने प्रकार के लिए define a mapping कर सकते हैं:

"autocomplete_questions": { 
    "_boost" : { 
     "name" : "po", 
     "null_value" : 1.0 
    }, 
    "properties": { 
      "po": { 
       "type": "double" 
      }, 
      "text": { 
       "type": "string", 
       "boost": 3.0, 
       "search_analyzer" : "str_search_analyzer", 
       "index_analyzer" : "str_index_analyzer" 
      }   
    } 
} 

और उसके बाद ही, आप नदी बना सकते हैं:

curl -XPUT "localhost:9200/_river/autocompleteindex/_meta" -d ' 
{ 
"type": "mongodb", 
"mongodb": { 
    "host": "rahulg-dc", 
    "port": "27017", 
    "db": "qna", 
    "collection": "autocomplete_questions" 
}, 
"index": { 
    "name": "autocompleteindex", 
    "type": "autocomplete_questions"} } 

क्या इससे मदद मिलती है?

+0

बहुत बहुत धन्यवाद। यह मेरे लिए काम किया। – Rahul

+0

बहुत धन्यवाद आदमी! यह वास्तव में काम करता है =) – rusllonrails

संबंधित मुद्दे