Mapping Problems

Hello, I am new in ElasticSearch, I am trying to create a new mapping with this request:

PUT /my_index/_mapping
    {
        "mappings": {
            "properties": {
                "avatar": {
                    "type": "text"
                },
                "category": {
                    "type": "text"
                },
                "createAt": {
                    "type": "long"
                },
                "description": {
                    "type": "text"
                },
                "images": {
                    "type": "text"
                },
                "likes": {
                    "type": "long"
                },
                "geohash": {
                    "type": "geo_point"
                },
                "location": {
                    "type": "geo_point"
                },
                "name": {
                    "type": "text"
                },
                "pid": {
                    "type": "text"
                },
                "price": {
                    "type": "long"
                },
                "profile": {
                    "type": "text"
                },
                "subCategory": {
                    "type": "text"
                },
                "thumbnail": {
                    "type": "text"
                },
                "totalComments": {
                    "type": "long"
                },
                "uid": {
                    "type": "text"
                }
            }
        }
    }

But I get a error:

    {
      "error" : {
        "root_cause" : [
          {
            "type" : "mapper_parsing_exception",
            "reason" : "Root mapping definition has unsupported parameters:  [mappings : {properties={images={type=text}, subCategory={type=text}, thumbnail={type=text}, profile={type=text}, description={type=text}, pid={type=text}, avatar={type=text}, createAt={type=long}, uid={type=text}, totalComments={type=long}, price={type=long}, name={type=text}, category={type=text}, likes={type=long}}}]"
          }
        ],
        "type" : "mapper_parsing_exception",
        "reason" : "Root mapping definition has unsupported parameters:  [mappings : {properties={images={type=text}, subCategory={type=text}, thumbnail={type=text}, profile={type=text}, description={type=text}, pid={type=text}, avatar={type=text}, createAt={type=long}, uid={type=text}, totalComments={type=long}, price={type=long}, name={type=text}, category={type=text}, likes={type=long}}}]"
      },
      "status" : 400
    }

I want to use geo_point search, my original location object was.

    "location": {
        "geohash": "66jc35pfy",
        "geopoint": [
            "33.513291022392195° S",
            "70.60919690877199° W"
        ]
    }

But I don't know what is the best mapping for that. I change the mapping to separate each attribute as I showed in the request above. If anyone can help me.
Thanks

This one worked for me;

PUT my_index
{
  "mappings": {
    "properties": {
      "avatar": {
        "type": "text"
      },
      "category": {
        "type": "text"
      },
      "createAt": {
        "type": "long"
      },
      "description": {
        "type": "text"
      },
      "images": {
        "type": "text"
      },
      "likes": {
        "type": "long"
      },
      "geohash": {
        "type": "geo_point"
      },
      "location": {
        "type": "geo_point"
      },
      "name": {
        "type": "text"
      },
      "pid": {
        "type": "text"
      },
      "price": {
        "type": "long"
      },
      "profile": {
        "type": "text"
      },
      "subCategory": {
        "type": "text"
      },
      "thumbnail": {
        "type": "text"
      },
      "totalComments": {
        "type": "long"
      },
      "uid": {
        "type": "text"
      }
    }
  }
}

Thanks, I change to:

    "location": {
        "properties": {
            "geohash": {
                "type": "geo_point"
            },
            "geopoint": {
                "type": "geo_point"
            }
        }
    },
1 Like