salyh/elasticsearch-imap

Example with type_mapping

megastef opened this issue · 6 comments

I would like to add mapping for https://github.com/jprante/elasticsearch-langdetect
and get possibility to sort by receivedDate - so a custom mapping is required.

There is no documentation, what is expected in

 type_mapping - optional mapping for the Elasticsearch index type

I tried this:

"type_mapping" : {

                        "properties" : {
                           "textContent" : { "type" : "langdetect" },
                           "receivedDate" : { "type": "date"}
                        }

                    }

River creation was OK, but mapping not applied.
Then I used this one:

"type_mapping" : {
                      "mail" : {
                        "properties" : {
                           "textContent" : { "type" : "langdetect" },
                           "receivedDate" : { "type": "date"}
                        }
                      }
                    }

No effect on mapping. Of course I deleted river and index on each try ..

In both cases I got following response:

{"_index":"_river","_type":"stefan","_id":"_meta","_version":1,"created":true}

The second is the one that should work. Unfortunately there is a bug in 0.0.6 preventing this. Try http://dl.bintray.com/salyh/maven/de/saly/elasticsearch/plugin/elasticsearch-river-imap/0.0.7-b11/elasticsearch-river-imap-0.0.7-b11-plugin.zip

OK. Mapping got applied (not the one in the example, but another), I might update you when it works like I want. E.g. E-Mail address should be "not_analyzed" or multi-field (e.g. to make stats about sender/recipient).

This mapping works for me now:

{
                      "mail" : {
                        "properties" : {
                           "textContent" : { "type" : "langdetect" },
                           "email" : {"type":"string", "index":"not_analyzed"},

                           "subject": {
                               "type": "multi_field",
                               "fields": {
                                   "text": { "type": "string" },
                                   "raw":   { "type": "string", "index": "not_analyzed" }
                               }
                           },
                           "personal": {
                              "type": "multi_field",
                              "fields": {
                                  "title": { "type": "string" },
                                  "raw":   { "type": "string", "index": "not_analyzed" }
                              }
                          }
                        }
                      }
}

Will think about changing the default mapping as you suggested.

Think you have typo in mapping: its sentDate instead of sendDate

documentation updated with c32b262