2014-06-18 12 views
7

मैं अपने रेल ऐप में elasticsearch-rails मणि का उपयोग कर रहा हूं ताकि Elasticsearch के साथ एकीकरण को सरल बनाया जा सके। मैं phonetic analysis plugin का उपयोग करने की कोशिश कर रहा हूं, इसलिए मुझे अपने सूचकांक के लिए कस्टम विश्लेषक और कस्टम फ़िल्टर को परिभाषित करने की आवश्यकता है।कस्टम विश्लेषक elasticsearch-rails

मैं आदेश में एक soundex ध्वन्यात्मक फिल्टर के साथ कस्टम विश्लेषण करने के लिए में कोड के इस टुकड़े कोशिश की, लेकिन यह एक अपवाद संदेश के साथ विफल रहता है:

[!!!] त्रुटि जब सूचकांक बनाने: Elasticsearch: : परिवहन :: परिवहन :: त्रुटियां :: BadRequest [400] {"त्रुटि": "मैपरपरिंग अपवाद [मैपिंग [call_sentence]]; नेस्टेड: मैपरपरिंग अपवाद [विश्लेषक [{टोकनज़र = मानक, फ़िल्टर = [मानक, लोअरकेस, मेटाफोनर]} ] क्षेत्र [फोनेटिक]] के लिए नहीं मिला; "," स्थिति ": 400}

# Set up index configuration and mapping 
# 
settings index: { number_of_shards: 1, number_of_replicas: 0 } do 
    mapping do 
    indexes :text, type: 'multi_field' do 
     indexes :processed, analyzer: 'snowball' 
     indexes :phone, {analyzer: { 
     tokenizer: "standard", 
     filter: ["standard", "lowercase", "metaphoner"] 
     }, filter: { 
     metaphoner: { 
      type: "phonetic", 
      encoder: "soundex", 
      replace: false 
     } 
     }} 
     indexes :raw, analyzer: 'keyword' 
    end 
    end 
end 

उत्तर

2

ठीक है, मैं elasticsearch.yml config संशोधित ध्वन्यात्मक विश्लेषक

#################################### Index #################################### 
index: 
    analysis: 
    analyzer: 
     phonetic_analyzer: 
     tokenizer: standard 
     filter: [metaphoner] 
    filter: 
     metaphoner: 
     type: phonetic 
     encoder: doublemetaphone 
     replace: true 
13

आप भी इसे निर्दिष्ट कर सकते हैं में कॉल सेटिंग शामिल करने के लिए:

settings index: { 
    number_of_shards: 1, 
    number_of_replicas: 0, 
    analysis: { 
     filter: { 
     metaphoner: { 
      type: 'phonetic', 
      encoder: doublemetaphone, 
      replace: true, 
     } 
     }, 
     analyzer: { 
     phonetic_analyzer: { 
      tokenizer: 'standard', 
      filter: ["standard", "lowercase", "metaphoner"], 
     } 
     } 
    } 
    } do 
    mapping do 
     indexes :text, type: 'multi_field' do 
     indexes :processed, analyzer: 'snowball' 
     indexes :phone, analyzer: 'phonetic_analyzer' 
     indexes :raw, analyzer: 'keyword' 
     end 
    end 
end 
संबंधित मुद्दे