neo4j-elasticsearch icon indicating copy to clipboard operation
neo4j-elasticsearch copied to clipboard

Allow for basic mapping of types in ES on index creation

Open alank64 opened this issue 9 years ago • 5 comments

It's really cool that this plugin defines mapping on index creation, however in some cases it doesn't always work to your advantage due to lack of mapping definitions in the properties.

ES assumes type cohesion where say <id:5> n.vin = "57784930" and <id:9> n.vin = "XX349494", if on first passing the vin with only numbers, even though should be a string, ES will map the type to long.

...
"mappings": {
  "Vehicle": {
    "properties": {
      "id": {
        "type": "string"
      },
      "vin": {
        "type": "long"
      },
      "labels": {
        "type": "string"
      }
      "uuid": {
        "type": "string"
      }
    }
  }
}  ...

A suggestion would be to enforce types, therefore sending a mapping with the type, then letting ES detect the others, a suggestion could be:

elasticsearch.index_spec=vehicles:Vehicle(uuid,vin(type:string),sale_class), ...

However the better option would be to allow the full definitions of the mapping allowing for things like not-analyzed and custom tokenizers etc.

A potential (haven't tried this out yet) workaround is to use ES PUT mapping definition after the index/mapping is created, and then re-index everything.

alank64 avatar Nov 07 '15 12:11 alank64

So it would make sense to have a full index definition json file to refer to?

elasticsearch.index_file=elasticsearch_index.json ?

jexp avatar Dec 20 '16 20:12 jexp

Do you think you could help us by providing a PR ?

jexp avatar Dec 20 '16 20:12 jexp

Ping @alank64

jexp avatar Jun 03 '17 20:06 jexp

Does it now support using a full index definition JSON file?

xkcoding avatar Sep 26 '18 03:09 xkcoding

I am also interested in this. Currently all of my fields are being mapped as keyword which doesn't allow more specific querying of the index. I also tried updating the mapping with ES PUT after the creation, but I got an error resource_already_exists_exception

mvid avatar Oct 10 '18 16:10 mvid