2014年5月14日 星期三

[elasticsearch] multi index 多個index / exclude search for index


使用 elasticsearch 來索引資料 , 可以預先不用建立好 index mapping  (solr 稱作 scheme.xml ),他使用隱式的方式帶入 json input 的 類型。

Multiple Indices

大部分的 ElasticSearch api都支援再 index 這個parameter 使用 multiple indices 的操作。

舉例來說,我們有多個index,pc_index1,pc_index2,pc_index3

我們在使用api使就可以使用 "pc_index1,pc_index2,pc_index3"傳入 index 的 parameter。(或者是使用 "_all" 來表示 所有的index)

甚至在這裡可以使用 * wildcard 的 表示式。

"pc_*" 透過使用這樣來matching index name。


exclude index 排除 索引名稱

實際運用上,可能我們會使用 wildcard來 對index prefix 來matching一些index name。不過,可能有種情況,我們要search 大部分的 index ,但是想要排除,特定的幾個索引呢?

elasticsearch在 multi index的操作上也提供 "remove" 方式,
舉例來說,
"+pc_*,-pc_index3"
我們排除搜尋 pc_index3 這個索引。



沒有留言:

張貼留言