添加同义词后,无法在弹性搜索中搜索字符串

时间:2016-03-17 08:46:40

标签: php magento elasticsearch

我在elasticsearch中实现了同义词,但现在我遇到了问题。整个字符串在空格上分割,我无法使用"查看所有结果选项"。 这是我的设置。

$indexSettings['analysis']['analyzer'] = array(
            'std' => array( // Will allow query 'shoes' to match better than 'shoe' which the stemmed version
                'tokenizer' => 'standard',
                'char_filter' => 'html_strip', // strip html tags
                'filter' => array('standard', 'elision', 'asciifolding', 'lowercase', 'stop', 'length'),
            ),
            'keyword' => array(
                'tokenizer' => 'keyword',
                'filter' => array('asciifolding', 'lowercase'),
            ),
            'keyword_prefix' => array(
                'tokenizer' => 'keyword',
                'filter' => array('asciifolding', 'lowercase', 'edge_ngram_front'),
            ),
            'text_prefix' => array(
                'tokenizer' => 'standard',
                'char_filter' => 'html_strip', // strip html tags
                'filter' => array('standard', 'elision', 'asciifolding', 'lowercase', 'stop', 'edge_ngram_front'),
            ),
            'text_suffix' => array(
                'tokenizer' => 'standard',
                'char_filter' => 'html_strip', // strip html tags
                'filter' => array('standard', 'elision', 'asciifolding', 'lowercase', 'stop', 'edge_ngram_back'),
            ),
            'synonym' => array(
                'tokenizer' => 'standard',
                'type' => 'custom',
                'char_filter' => 'html_strip', // strip html tags
                'filter' => array('standard','synonym', 'elision', 'asciifolding', 'kstem', 'length','snowball' ,'lowercase', 'stop',)
            ),

        );
        $indexSettings['analysis']['filter'] = array(
            'edge_ngram_front' => array(
                'type' => 'edgeNGram',
                'min_gram' => 2,
                'max_gram' => 10,
                'side' => 'front',
            ),
            'edge_ngram_back' => array(
                'type' => 'edgeNGram',
                'min_gram' => 2,
                'max_gram' => 10,
                'side' => 'back',
            ),
            'stop' => array(
                'type' => 'stop',
                'stopwords' => '_none_',
            ),
            'length' => array(
                'type' => 'length',
                'min' => 2,
            ),
            'synonym' => array(
                'type' => 'synonym',
                'expand' => true,
                'synonyms_path' => 'synonyms.txt',
            ),
        );
         $properties[$key]['analyzer'] = 'synonym';

在下拉列表中,我给出5个结果显示,一个选项查看所有结果。 寻找"抗Ssl样蛋白"我得到这个词q = Anti ssl =""像=""蛋白质=""在锚标签中查看所有结果。可以看到所有结果选项获得完整的单词。

0 个答案:

没有答案