Update Database Structure Process - sfu-innovation/big-data GitHub Wiki

Because We can't sort things in current database structure, an update is required.

  1. open your elasticsearch head, open the any request tab

  2. in url filed , put in http://localhost:9200/big-data/magic-cards/

  3. in the following command filed, put in _mapping

  4. select PUT in the request type dropdown list

  5. put the following query in and hit "request" button

{
    "magic-cards": {
        "properties": {
            "cost": {
                "type": "multi_field",
                "fields": {
                    "cost": {
                        "type": "string"
                    },
                    "untouched": {
                        "type": "string",
                        "index": "not_analyzed"
                    }
                }
            },
            "description": {
                "type": "multi_field",
                "fields": {
                    "description": {
                        "type": "string"
                    },
                    "untouched": {
                        "type": "string",
                        "index": "not_analyzed"
                    }
                }
            },
            "icon": {
                "type": "multi_field",
                "fields": {
                    "icon": {
                        "type": "string"
                    },
                    "untouched": {
                        "type": "string",
                        "index": "not_analyzed"
                    }
                }
            },
            "id": {
                "type": "multi_field",
                "id": {
                    "id": {
                        "type": "string"
                    },
                    "untouched": {
                        "type": "string",
                        "index": "not_analyzed"
                    }
                }
            },
            "mechanics": {
                "type": "multi_field",
                "fields": {
                    "mechanics": {
                        "type": "string"
                    },
                    "untouched": {
                        "type": "string",
                        "index": "not_analyzed"
                    }
                }
            },
            "name": {
                "type": "multi_field",
                "fields": {
                    "name": {
                        "type": "string"
                    },
                    "untouched": {
                        "type": "string",
                        "index": "not_analyzed"
                    }
                }
            },
            "set": {
                "type": "multi_field",
                "fields": {
                    "set": {
                        "type": "string"
                    },
                    "untouched": {
                        "type": "string",
                        "index": "not_analyzed"
                    }
                }
            },
            "type": {
                "type": "multi_field",
                "fields": {
                    "type": {
                        "type": "string"
                    },
                    "untouched": {
                        "type": "string",
                        "index": "not_analyzed"
                    }
                }
            }
        }
    }
}
  1. wait until you get a succuess reply message
{
"ok": "true",
"acknowledged": "true"
}

##Test

  1. REINDEX YOUR DATABASE DATA by import the backup json file we had before using the import tool

$node index.js -f backup.json

  1. if you have updated the structure sucessfully, you should able to run the following query using POST and _search
{
    "sort": [{
        "name.untouched": "asc"
    }],
    "query": {
        "bool": {
            "must": [{
                "prefix": {
                    "name": ""
                }
            }]
        }
    },
    "from": 0,
    "size": 60
}

if everything went right, you should able to see the result sorted by card name