neo4j-contrib / neo4j-elasticsearch

Neo4j ElasticSearch Integration
Apache License 2.0
210 stars 79 forks source link

Allow for basic mapping of types in ES on index creation #15

Open alank64 opened 8 years ago

alank64 commented 8 years ago

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.

jexp commented 7 years ago

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

elasticsearch.index_file=elasticsearch_index.json ?

jexp commented 7 years ago

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

jexp commented 7 years ago

Ping @alank64

xkcoding commented 5 years ago

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

mvid commented 5 years ago

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