<#escape x as x?xml>
<?xml version="1.0"?>
<component name="org.nuxeo.elasticsearch.index.audit.contrib">
  <require>org.nuxeo.elasticsearch.ElasticSearchComponent</require>

  <extension target="org.nuxeo.elasticsearch.ElasticSearchComponent"
	     point="elasticSearchIndex">

    <elasticSearchIndex name="${audit.elasticsearch.indexName}" type="entry" >
      <settings>{
<#if "${elasticsearch.addressList}" != "">
   "number_of_shards" : "${elasticsearch.indexNumberOfShards}",
   "number_of_replicas" : "${elasticsearch.indexNumberOfReplicas}",
</#if>
   "analysis" : {
      "filter" : {
         "truncate_filter" : {
            "length" : 256,
            "type" : "truncate"
         },
         "word_delimiter_filter" : {
           "type" : "word_delimiter",
           "preserve_original" : true
         },
         "en_stem_filter" : {
            "name" : "minimal_english",
            "type" : "stemmer"
         },
         "en_stop_filter" : {
            "stopwords" : [
               "_english_"
            ],
            "type" : "stop"
         }
     },
      "tokenizer" : {
         "path_tokenizer" : {
            "delimiter" : "/",
            "type" : "path_hierarchy"
         }
      },
      "analyzer" : {
         "en_analyzer" : {
            "alias" : "fulltext",
            "char_filter":  [ "html_strip"],
            "filter" : [
               "word_delimiter_filter",
               "lowercase",
               "en_stop_filter",
               "en_stem_filter"
            ],
            "type" : "custom",
            "tokenizer" : "standard"
         },
         "path_analyzer" : {
            "type" : "custom",
            "tokenizer" : "path_tokenizer"
         },
        "default" : {
            "type" : "custom",
            "filter" : [ "truncate_filter" ],
            "tokenizer" : "keyword"
         }
      }
   }
}
      </settings>
      <mapping>
        {
           "_all" : {
             "analyzer" : "fulltext"
          },
          "properties" : {
            "id" : {
              "type" : "long"
            },
            "comment" : {
              "type" : "multi_field",
              "fields" : {
                "comment" : {
                  "type" : "string"
                },
                "fulltext" : {
                  "type": "string",
                  "analyzer" : "fulltext"
                }
              }
            },
	    "eventDate": {
	      "format": "dateOptionalTime",
	      "type": "date"
	    },
	    "logDate": {
	      "format": "dateOptionalTime",
	      "type": "date"
	    },
            "docPath": {
              "type" : "multi_field",
              "fields" : {
                "children" : {
                  "analyzer" : "path_analyzer",
                  "search_analyzer" : "keyword",
                  "type" : "string"
                },
                "docPath" : {
                  "index" : "not_analyzed",
                  "type" : "string"
                }
              }
            }
          }
        }
      </mapping>
    </elasticSearchIndex>

  </extension>

</component>
</#escape>
