salyh / elasticsearch-imap

IMAP and POP3 email importer for Elasticsearch (no river anymore)
Apache License 2.0
100 stars 25 forks source link

Example with type_mapping #4

Closed megastef closed 10 years ago

megastef commented 10 years ago

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}
salyh commented 10 years ago

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

megastef commented 10 years ago

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).

megastef commented 10 years ago

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" }
                              }
                          }
                        }
                      }
}
salyh commented 10 years ago

Will think about changing the default mapping as you suggested.

salyh commented 10 years ago

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

salyh commented 10 years ago

documentation updated with https://github.com/salyh/elasticsearch-river-imap/commit/c32b26236284eef23720e2cad9db4dfa7bed8548