Update Database Structure Process - sfu-innovation/big-data GitHub Wiki
Because We can't sort things in current database structure, an update is required.
-
open your elasticsearch head, open the any request tab
-
in url filed , put in
http://localhost:9200/big-data/magic-cards/
-
in the following command filed, put in
_mapping
-
select
PUT
in the request type dropdown list -
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"
}
}
}
}
}
}
- wait until you get a succuess reply message
{
"ok": "true",
"acknowledged": "true"
}
##Test
- REINDEX YOUR DATABASE DATA by import the backup json file we had before using the import tool
$node index.js -f backup.json
- 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