2016-12-29 5 views
0
私はelasticsearchクラスタバージョン1.7.2を使用して、この文字を無視するフィールドのいずれかのマッピング(と思う)を変更しようとしている

に変更マッピング:「 - 」ElasticSearch - フィールド

フィールド「Request.Headers.Host」は、その値は含めることができます「 - 」のような: 「app-cdn.cap.com」

#curl -X GET http://10.2.5.181:9200?pretty 
{ 
    "status" : 200, 
    "name" : "log-zone-a", 
    "cluster_name" : "cap-logs", 
    "version" : { 
    "number" : "1.7.2", 
    "build_hash" : "e43676b1385b7f593f7202acbd816e8ec", 
    "build_timestamp" : "2015-09-14T09:49:53Z", 
    "build_snapshot" : false, 
    "lucene_version" : "4.10.4" 
    }, 
    "tagline" : "You Know, for Search" 
} 

私はそれがnot_analyzedパラメータに関連しています見て、私は「何から私はこれを試しました:

#curl -X PUT '{"mappings":{"logs":{"properties":{"Request.Headers.Host":{"type":"string","index":"not_analyzed"}}}}}' http://10.2.5.181:9200/logstash-2016.12.27/logs/_mapping?pretty 
curl: (3) [globbing] nested braces not supported at pos 13 
{ 
    "error" : "ActionRequestValidationException[Validation Failed: 1: mapping source is empty;]", 
    "status" : 400 
} 
#curl -H 'Accept: application/json' -X PUT http://10.2.5.181:9200/logstash-2016.12.27?pretty -d @/home/moses/mapping.json 
{ 
    "error" : "RemoteTransportException[[log-zone-b][inet[/10.2.105.181:9300]][indices:admin/create]]; nested: IndexAlreadyExistsException[[logstash-2016.12.27] already exists]; ", 
    "status" : 400 
} 

#cat /home/moses/mapping.json | jq . 
{ 
    "logstash-2016.12.27": { 
    "mappings": { 
     "logs": { 
     "properties": { 
      "Request.Headers.Host": { 
      "type": "string", 
      "index": "not_analyzed" 
      } 
     } 
     } 
    } 
    } 
} 

私はマッピングを変更し、非既存のインデックスのために同じことをやって、それは成功だが、インデックスが間違っているようだよ、ドットで「Request.Headers.Host」を分離:(

#cat /home/moses/mapping.json 
{"Request.Headers.Host":{"type":"string","index":"not_analyzed"}} 

    #curl -H 'Accept: application/json' -X PUT http://10.2.5.181:9200/logstash-2016.12.30?pretty -d @/home/moses/mapping.json 
    { 
     "acknowledged" : true 
    } 

#curl -H 'Accept: application/json' -X GET http://10.2.5.181:9200/logstash-2016.12.30?pretty 
{ 
"logstash-2016.12.30" : { 
"aliases" : { }, 
"mappings" : { }, 
"settings" : { 
    "index" : { 
    "creation_date" : "1483011476137", 
    "Request" : { 
     "Headers" : { 
     "Host" : { 
      "type" : "string", 
      "index" : "not_analyzed" 
     } 
     } 
    }, 
    "uuid" : "M6Ly0wvwTGu1aulSViYcPg", 
    "number_of_replicas" : "1", 
    "number_of_shards" : "5", 
    "version" : { 
     "created" : "1070299" 
    } 
    } 
}, 
"warmers" : { } 
    } 
} 

私はどのように設定しますこの種のマッピング構成は、現在のインデックスと将来のインデックスにマッピングされますか?

おかげで、 モシェ

+0

あなたはマッピングを更新することはできません既存のフィールドのために。ここでは2つの回避策があります。1)更新されたマッピングでデータ全体を再索引付けします。ただし、データのインデックスを作成する前にマッピングを配置してください。 2)既存のインデックスに新しい 'not_analyzed'フィールドを追加します。 [参照-1](http://stackoverflow.com/questions/25471715/create-or-update-mapping-in-elasticsearch)、[参照-2](http://stackoverflow.com/questions/16290636/how更新のためのフィールドタイプのエラスティックサーチ) – Roopendra

+0

ハイフンについて:[ElasticSearch - ハイフンで検索する]を参照してください(http://stackoverflow.com/questions/30917043/elasticsearch-searching-with-hyphens) – rvheddeg

+0

@rvheddeg ダッシュボードを作成するときにハイフンに問題があります。"Request.Headers.Host": "app-cdn.cap.com" の値を "app"と "cdn .cap.com " –

答えて

0

正しく「Request.Headers.Host」のような内部フィールドのマッピングを設定するには、複数のレベルを定義する必要があります。

{ 
    "logs" : { 
    "properties" : { 
     "Request" : { 
     "properties" : { 
      "Headers" : { 
      "properties": { 
       "Host": { 
       "type" : "string", 
       "index": "not_analyzed" 
       } 
      } 
      } 
     } 
     } 
    } 
    } 
} 
+0

@ AlainCollinsに感謝します! 私はESのかなりのnoobです、どのようにこのマッピングを将来のインデックスに固定するのですか? –

+0

将来のインデックスのマッピングを設定するには、[テンプレート](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html)を使用します。 –

+0

thanks @ AlainCollins特定のインデックス(名前:logstash-2016.02.01など)のデフォルトマッピングを設定するにはどうすればよいですか? 各フィールドを指定せずにそのインデックスが "not_analyzed"になるようにデフォルトが必要です。 –

関連する問題