2013-04-15 19 views
0

我试图让ES QueryString匹配包含“and”的搜索词,但我迄今试过的所有内容(尝试不同的分析仪,令牌仪,过滤器)没有工作。在MySQL方面,我要的是:ElasticSearch/Elastica:搜索包含“and”或其他停用词的确切词语

WHERE field LIKE '%abbot and costello%' 

我已经试过各种配置,这是我目前使用的是什么(因为它“方丈”匹配略有改善(与尾随的空间),但仍然没有它匹配任何东西“和”:

$eI->create(array(
    'analysis' => array(
     'analyzer' => array(
      'indexAnalyzer' => array(
       'type' => 'custom', 
       'tokenizer' => 'SQLedgeNGram', 
       'filter' => array(
        'lowercase', 
       ), 
      ), 
      'searchAnalyzer' => array(
       'type' => 'custom', 
       'tokenizer' => 'SQLedgeNGram', 
       'filter' => array(
        'lowercase', 
       ), 
      ) 
     ), 
     'tokenizer' => array(
      'SQLedgeNGram' => array(
       'type' => 'edgeNGram', 
       'min_gram' => 2, 
       'max_gram' => 35, 
       'side' => 'front' 
      ), 
      'standardNoStop' => array(
       'type' => 'standard', 
       'stopwords' => '' 
      ) 
     ) 
    ) 
), true 
); 

这里是我的测试用例字段值:

Abbott and Costello - Funniest Routines, Vol. 

尝试各种分析仪,我似乎无法得到它匹配任何包含“和“

结果:

searching [abbot] 
@  searchAnalyzer   total results: 1 
@  standard    total results: 1 
@  simple     total results: 1 
@  whitespace    total results: 1 
@  keyword     total results: 1 


searching [abbot ] 
@  searchAnalyzer   total results: 1 
@  standard    total results: 1 
@  simple     total results: 1 
@  whitespace    total results: 1 
@  keyword     total results: 1 


searching [abbot and c] 
    searchAnalyzer   total results: 0 
    standard    total results: 0 
    simple     total results: 0 
    whitespace    total results: 0 
    keyword     total results: 0 


searching [abbot and cost] 
    searchAnalyzer   total results: 0 
    standard    total results: 0 
    simple     total results: 0 
    whitespace    total results: 0 
    keyword     total results: 0 


searching [abbot and costello] 
    searchAnalyzer   total results: 0 
    standard    total results: 0 
    simple     total results: 0 
    whitespace    total results: 0 
    keyword     total results: 0 


searching [abbot costello] 
    searchAnalyzer   total results: 0 
    standard    total results: 0 
    simple     total results: 0 
    whitespace    total results: 0 
    keyword     total results: 0 

回答

1

您在查询中有错字(雅培缺少第二个T)。你也不需要通过ngram进行搜索。搜索标记器可以是关键字,它仍然适用于短于35个字符的短语。顺便说一句,edgeNGram只会给你尾随通配符。对于前导和尾随通配符,您需要使用nGram滤镜。

+0

我知道这是一个简单的答案,但感谢您花时间指出问题,这使我很悲伤..检查了一切,但最明显的:( – Eva

相关问题