richardwilly98 / elasticsearch-river-mongodb

MongoDB River Plugin for ElasticSearch
1.12k stars 215 forks source link

Dynamic mapping geopoint doesn't work #399

Open fedcecca opened 9 years ago

fedcecca commented 9 years ago

I don't know if it is a bug or it is a my mistake. I'm using elasticsearch river to import a Mongo DB collection into elasticsearch. The collection have a geo point field (position.loc).

If I try to query using the geo point field using the following query:

{

 "query" : {
        "match_all" : {}
    }, 
   "filter" : {
        "geo_distance" : {
            "distance" : "12km",
            "position.loc" : [45.07085, 7.684341]
        }
    }

}

I receive the following error message:

Caused by: org.elasticsearch.index.query.QueryParsingException: [places2_idx] failed to find geo_point field [position.loc]

When I query the mapping I receive the following info about position.loc field :+1: "position": { "properties": { "loc": { "properties": { "coordinates": { "type": "double" }, "index": { "type": "string" }, "type": { "type": "string" } } } } }

I think that the mapping is incorrect. How can I force river to map the field correctly?

Thanks in advance.

richardwilly98 commented 9 years ago

You should define a customer mapping. See #105. There are also few geopoint closed issues: https://github.com/richardwilly98/elasticsearch-river-mongodb/issues/218#issuecomment-35824681

fedcecca commented 9 years ago

thanks you for your answer, I have a complex document JSon structure. How I can customize the mapping? I have to specify all field into document structure or I can overide only the position.loc mapping. Do you have any exemples? I have created the index (and MongoDB mapping) using the service: POST http://:9200/_river/mongodb/_meta { "type": "mongodb", "mongodb": { "db": " ", "collection": "" }, "index": { "name": "<COLLECTION_idx", "type": "places" } }

Do I have to create before a type "places" for the "index" and after run the same command (POST http://:9200/_river/mongodb/_meta)?

Thanks in advance.