是否可以創建索引,限制索引父屬性?ElasticSearch創建具有動態屬性的索引
例如,
$ curl -XPOST 'http://localhost:9200/actions/action/' -d '{
"user": "kimchy",
"message": "trying out Elasticsearch",
"actionHistory": [
{ "timestamp": 123456789, "action": "foo" },
{ "timestamp": 123456790, "action": "bar" },
{ "timestamp": 123456791, "action": "buz" },
...
]
}'
我不想actionHistory
在所有索引。如何才能做到這一點?
對於上述文件,我相信該指數將作爲
$ curl -XPOST localhost:9200/actions -d '{
"settings": {
"number_of_shards": 1
},
"mappings": {
"action": {
"properties" : {
"user": { "type": "string", "index" : "analyzed" },
"message": { "type": "string": "index": "analyzed" },
"actionHistory": {
"properties": {
"timestamp": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
},
"action": { "type": "string", "index": "analyzed" }
}
}
}
}
}
}'
會去除actionHistory
properties
與"index": "no"
替換它是妥善解決產生的呢?
這是一個例子,但是我的實際情況是具有動態屬性的文檔(即actionHistory
包含各種自定義的,非重複的屬性),我的這個特定類型的映射定義有超過2000個不同的屬性,慢(即比數據庫中的全文搜索最差)。
嗯,你的搜索查詢是如何構建的,因爲'actionHistory'如此不同使得它們表現不佳?你在搜索或字段名稱通配符中使用了'_all'嗎? –
是的,我讓用戶使用'query_string'形式。 –
這就是允許用戶用'query_string'完成他們想做的任何事情的缺點。同樣,允許用戶在所有文檔中創建_various自定義非重複屬性。您可以從這些任意的query_strings中獲得各種問題,並在文檔中擁有任何屬性。我建議限制這些自由以獲得更穩定和可預測的羣集。 –