2015-10-09 138 views
0

例如查询我有内容“FileV2UpdateRequest”的记录,并根据我的分析,将打破纪录成标记:ElasticSearch查询字符串查询通配符与多个令牌

  • filev
  • updaterequest

我希望能够搜索filev2update*在“QUERY_STRING”查询来找到它,但无论什么原因,没有按*”试着像找到应该的那样找到'updaterequest'的其余部分。

如果我输入查询filev2 update*它会返回结果。

有什么我可以做的,使空间不需要的地方工作?

我已经尝试使用auto_generate_phrase_queries设置为true,但那也不能解决问题。看起来像添加通配符符号时,它将整个输入视为一个标记,而不仅仅是查看通配符正在接触的标记。

如果我添加analyze_wildcard并将其设置为true,它会尝试将*放在查询中的每个标记上。 costv * 2 *添加*

回答

0

我想你可以通过使用word_delimiter索引您的内容更改索引过滤Compound Word Token Filter

如果使用这种过滤

FileV2UpdateRequest将浅析浅析,以代币:

{ 
    "tokens": [{ 
     "token": "File", 
     "start_offset": 0, 
     "end_offset": 4, 
     "type": "word", 
     "position": 1 
    }, { 
     "token": "V", 
     "start_offset": 4, 
     "end_offset": 5, 
     "type": "word", 
     "position": 2 
    }, { 
     "token": "2", 
     "start_offset": 5, 
     "end_offset": 6, 
     "type": "word", 
     "position": 3 
    }, { 
     "token": "Update", 
     "start_offset": 6, 
     "end_offset": 12, 
     "type": "word", 
     "position": 4 
    }, { 
     "token": "Request", 
     "start_offset": 12, 
     "end_offset": 19, 
     "type": "word", 
     "position": 5 
    }] 
} 

和您还需要搜索内容使用word_delimiter as filter without use wild_card

filev2update将浅析浅析到令牌:

{ 
    "tokens": [{ 
     "token": "file", 
     "start_offset": 0, 
     "end_offset": 4, 
     "type": "word", 
     "position": 1 
    }, { 
     "token": "V", 
     "start_offset": 4, 
     "end_offset": 5, 
     "type": "word", 
     "position": 2 
    }, { 
     "token": "2", 
     "start_offset": 5, 
     "end_offset": 6, 
     "type": "word", 
     "position": 3 
    }, { 
     "token": "update", 
     "start_offset": 6, 
     "end_offset": 12, 
     "type": "word", 
     "position": 4 
    }] 
} 
+0

我确实有一些情况下,我有一个像File_V2_Update一个例子,我想_要在搜索中关系......不会的字分隔符忽略这些? – Nived

+0

它会忽略_,但为什么要搜索_? – chengpohi

+0

,因为如果我有File_V2_Update和FileV2Update,我希望它们可以区分 – Nived