0

Is dynamic mapping for geo point still working in Elastic Search 2.x/5.x?

This is the template:

{
        "template": "*",
        "mappings": {
            "_default_": {
                "dynamic_templates": [
                    {
                        "geo_point_type": {
                            "match_mapping_type": "string",
                            "match": "t_gp_*",
                            "mapping": {
                                "type": "geo_point"
                            }
                        }
                    }
                ]
            }
        }
    }

This is the error I get when I query the field:

"reason": "failed to parse [geo_bbox] query. field [t_gp_lat-long@en] is expected to be of type [geo_point], but is of [string] type instead"

I seems to remember that I saw somewhere in the documentation that this doesn't work, but I thought that's only when there is no dynamic template at all.

Any idea?


Update 1

Here's a sample of the document. The actual document is very big so I took the only relevant part of it.

{
    "_index": "route",
    "_type": "route",
    "_id": "583a014edd76239997fca5e4",
    "_score": 1,
    "_source": {
        "t_b_highway@en": false,
        "t_n_number-of-floors@en": 33,
        "updatedBy@_id": "58059fe368d0a739916f0888",
        "updatedOn": 1480196430596,
        "t_n_ceiling-height@en": 2.75,
        "t_gp_lat-long@en": "13.736248,100.5604997"
    }
}

Data looks correct to me since you can also index Geo Point field with lat/long string.


Update 2

Mapping is definitely wrong. That's why I'm wondering if you can dynamically map Geo Point field.

"t_gp_lat-long@en": {
    "type": "string",
    "fields": {
        "english": {
            "type": "string",
            "analyzer": "english"
        },
        "raw": {
            "type": "string",
            "index": "not_analyzed",
            "ignore_above": 256
        }
    }
},
Community
  • 1
  • 1
juminoz
  • 3,168
  • 7
  • 35
  • 52
  • Can you show a sample document that you're indexing? – Val Nov 29 '16 at 04:40
  • Small version of sample added. – juminoz Nov 29 '16 at 13:08
  • Can you also show the mapping of your `route` type? `curl -XGET localhost:9200/route/_mapping/route` – Val Nov 29 '16 at 14:04
  • Added relevant mapping. – juminoz Nov 29 '16 at 14:57
  • 1
    It worked for me. I created a new template with your template above and then indexed the sample document you provided and it worked ok, i.e. the `t_gp_lat-long@en` field was a `geo_point`. Looking at the mapping you provided, it looks like you have another template kicking in before the one with the `geo_point` field (maybe the default `logstash` template). Do you have other templates? If yes, in what order do they kick in? – Val Nov 29 '16 at 14:59
  • I think that could be the case. I have one that is trapping all string values to add not_analyzed and english. I will change the order and test it out after I figure out issue with upgrading to 5.0.1. I can't connect right now because SheildPlugin no longer works. – juminoz Nov 29 '16 at 15:06
  • Gotcha, let us know. – Val Nov 29 '16 at 15:09
  • I changed the order and it's working fine now. – juminoz Nov 29 '16 at 16:41
  • Awesome, glad you figured it out. – Val Nov 29 '16 at 16:47

0 Answers0