2015-10-09 135 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