2014-12-10 2 views
6

इंडेक्स में मैं निर्माण कर रहा हूं, मुझे एक क्वेरी चलाने में दिलचस्पी है, फिर (पहलुओं का उपयोग करके) उस क्वेरी के शिंगल लौट रहे हैं। यहाँ विश्लेषक मैं पाठ पर उपयोग कर रहा हूँ है:एलिंगस्टार्च और लुसेन के साथ शिंगल्स और स्टॉप शब्दों का उपयोग 4.4

{ 
    "settings": { 
    "analysis": { 
     "analyzer": { 
     "shingleAnalyzer": { 
      "tokenizer": "standard", 
      "filter": [ 
      "standard", 
      "lowercase", 
      "custom_stop", 
      "custom_shingle", 
      "custom_stemmer" 
      ] 
     } 
     }, 
     "filter": { 
     "custom_stemmer" : { 
      "type": "stemmer", 
      "name": "english" 
     }, 
     "custom_stop": { 
      "type": "stop", 
      "stopwords": "_english_" 
     }, 
     "custom_shingle": { 
      "type": "shingle", 
      "min_shingle_size": "2", 
      "max_shingle_size": "3" 
     } 
     } 
    } 
    } 
} 

प्रमुख मुद्दा यह है कि, Lucene 4.4 के साथ, फिल्टर रोक नहीं रह गया है enable_position_increments पैरामीटर का समर्थन दाद कि बंद शब्द होते हैं समाप्त करने के लिए है। इसके बजाय, मैं की तरह ..

"लाल और पीले"

"terms": [ 
    { 
     "term": "red", 
     "count": 43 
    }, 
    { 
     "term": "red _", 
     "count": 43 
    }, 
    { 
     "term": "red _ yellow", 
     "count": 43 
    }, 
    { 
     "term": "_ yellow", 
     "count": 42 
    }, 
    { 
     "term": "yellow", 
     "count": 42 
    } 
] 

स्वाभाविक रूप से यह बहुत लौटे दाद की संख्या से संबंध रखते परिणाम प्राप्त होगा। परिणाम पर पोस्ट-प्रोसेसिंग किए बिना इसे प्रबंधित करने के लिए ल्यूसीन 4.4 के बाद कोई तरीका है?

+1

आप इस समस्या के लिए एक समाधान मिला? – paweloque

+0

डुप्लिकेट प्रश्न: http://stackoverflow.com/questions/22609100/elasticsearch-shingles-with-stop-words-elimination – paweloque

उत्तर

6

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

"shingleAnalyzer": { 
     "tokenizer": "standard", 
     "filter": [ 
     "standard", 
     "lowercase", 
     "custom_stop", 
     "custom_shingle", 
     "custom_stemmer", 
     "kill_fillers" 
     ], 
     ... 

जोड़ें "kill_fillers" फिल्टर फिल्टर की अपनी सूची में: उदाहरण में नीचे मैं इसे "kill_fillers" कहा जाता है

"filters":{ 
... 
    "kill_fillers": { 
    "type": "pattern_replace", 
    "pattern": ".*_.*", 
    "replace": "", 
    }, 
... 
} 
2

im यकीन नहीं अगर यह मदद करता है, लेकिन दाद के लोचदार परिभाषा, आप पैरामीटर filler_token का उपयोग कर सकते हैं जो डिफ़ॉल्ट रूप से _ है। के लिए सेट, उदाहरण के लिए, एक खाली स्ट्रिंग:

$indexParams['body']['settings']['analysis']['filter']['shingle-filter']['filler_token'] = ""; 

https://www.elastic.co/guide/en/elasticsearch/reference/1.7/analysis-shingle-tokenfilter.html

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