0
votes

since a couple of days i got the problem that i can't solve:

What i want to happen: I got a collection that should be transferred to elasticsearch via https://github.com/richardwilly98/elasticsearch-river-mongodb bevor i create the river i set the custom mapping of the index, so that i don't get dynamic mapping that i can use the geo_point type in elasticsearch.

So first the mondel in Mongodb:

screenName: { type: String, required: true, unique: true, sparse: true },
firstName: { type: String, validate: isString, index: true },
lastName: { type: String, validate: isString, index: true },
deleted: { type: Number, index: true, default: 0 },
homeBase: {
    type: {
        type: String,
        default: 'Point'
    },
    coordinates: [Number] // [<longitude>, <latitude>]
},
realTime: {
    type: {
        type: String,
        default: 'Point'
    },
    coordinates: [Number] // [<longitude>, <latitude>]
}

RealTime and homeBase are 2dSpheres

The Pre Mapping

{
"settings": {
    "mapper": {
        "dynamic": false
    }
},
"mappings": {
    "default": {
        "properties": {
            "firstName": {
                "type": "string"
            },
            "lastName": {
                "type": "string"
            },
            "screenName": {
                "type": "string"
            },

            "homeBase": {
                "type": "object",
                "properties": {
                    "coordinates": {
                        "type": "geo_point"
                    }
                }
            },
            "realTime": {
                "type": "object",
                "properties": {
                    "coordinates": {
                        "type": "geo_point"
                    }
                }
            }
        }
    }
}

Wich also works quite well and gets indexed Url to Call PUT localhost:9200/users

And now the River

{
"type": "mongodb",
"mongodb": {
  "servers": [
    {
      "host": "localhost",
      "port": "27017"
    }
  ],
  "options": "drop_collection",
  "db": "entities",
  "collection": "users"
},
"index": {
  "name": "users",
  "type": "documents"
}
}

Here i called PUT http://localhost:9200/_river/users/_meta What i recieve is { "error" : "IndexAlreadyExistsException[[users] already exists]", "status" : 400 }

For What do i need this? to do queries like

GET _search
{
"query": { 
"filtered": {
   "query": {
       "multi_match": {
                                "query": "mario",
                                "fields": ["firstName", "lastName",     "specialities"]
                            }
    },
    "filter" : {
        "mutate" {
         "convert" => { "homeBase.coordinates" => "geo_point"}   
        },
        "geo_bounding_box" : {
            "homeBase.coordinates" : {
                "top_left" : [1,100],
                "bottom_right" : [1,100]
            }
        }
    }
}
}
}

The standard how i got the location field is a double, if anyone knows a way to query for locations around coordinates on doubles it would also be fine.

Please help!

Mongodb: 2.6.5 River 2.0.4 Elasticsearch: 1.4.0

1

1 Answers

0
votes

I used Put to create the River instead of Post, which led to the problem that the strange error appeared that no documents where indexed.

I changed it to POST everything was fine.