elasticsearch

Get latest records in elastic search


Currently i am working on elastic search for my project. I need to display my records(latest first). i am using sort technique. "sort" => array(array('created_date' => 'desc')),

and my mapping everything in string. `"products":{

"properties":{
    "add_by":{
        "type":"string"
    },
    "categories":{
        "properties":{
            "category_name":{
                "type":"string"
            },
            "id":{
                "type":"string"
            }
        }
    },
    "company_logo":{
        "type":"string"
    },
    "company_name":{
        "type":"string"
    },
    "created_date":{
        "type":"string"
    },
    "id":{
        "type":"string"
    },
    "industries":{
        "properties":{
            "id":{
                "type":"string"
            },
            "industry_name":{
                "type":"string"
            }
        }
    },
    "location":{
        "type":"string"
    },
    "location_latitude":{
        "type":"string"
    },
    "location_longitude":{
        "type":"string"
    },
    "num_of_employees":{
        "type":"string"
    },
    "practice_areas":{
        "properties":{
            "id":{
                "type":"string"
            },
            "practice_area_image":{
                "type":"string"
            },
            "practice_area_name":{
                "type":"string"
            }
        }
    },
    "product_description":{
        "type":"string"
    },
    "product_image":{
        "type":"string"
    },
    "product_name":{
        "type":"string"
    },
    "product_rating":{
        "type":"string"
    },
    "status":{
        "type":"string"
    },
    "updated_date":{
        "type":"string"
    },
    "user_id":{
        "type":"string"
    },
    "user_sub_type":{
        "type":"string"
    },
    "user_type":{
        "type":"string"
    }
}

}` i think i might me update my mapping like id and created_date(both are update to integer and timestamp). Please help me how to update mapping for my-type(product).


Solution