Skip to content

Instantly share code, notes, and snippets.

@2arunpmohan
Last active January 5, 2019 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2arunpmohan/c31298870c36b98ace37a78ba7df6b60 to your computer and use it in GitHub Desktop.
Save 2arunpmohan/c31298870c36b98ace37a78ba7df6b60 to your computer and use it in GitHub Desktop.
bash scripts for "suggest" mapping example of suggest implementation
#!/bin/bash
if [ -z $1 ] ; then
echo "Please enter hostname"
exit
fi
hostname=$1
curl -XDELETE "http://$hostname:9200/suggest-simple"
echo
curl -X PUT "http://$hostname:9200/suggest-simple" -d '{
"settings": {
"index": {
"number_of_replicas": "1",
"number_of_shards": "5"
}
},
"mappings": {
"logs": {
"properties": {
"name": {
"type": "string"
},
"domain": {
"type": "string"
},
"postcode": {
"type": "string"
},
"nameSuggest": {
"type": "completion",
"context": {
"domain": {
"type": "category"
},
"postcode": {
"type": "category"
}
}
}
}
}
}
}'
#!/bin/bash
if [ -z $1 ] ; then
echo "Please enter hostname"
exit
fi
hostname=$1
curl -XDELETE "http://$hostname:9200/suggest-new"
echo
curl -X PUT "http://$hostname:9200/suggest-new" -d '{
"mappings": {
"suggest": {
"properties": {
"store_suggest": {
"context": {
"mallIdContext": {
"path": "mallId",
"default": [
"no mall Id"
]
}
},
"type": "completion"
},
"movie_suggest": {
"context": {
"mallIdContext": {
"path": "mallId",
"default": [
"no mall Id"
]
}
},
"type": "completion"
},
"pt_suggest": {
"context": {
"mallIdContext": {
"path": "mallId",
"default": [
"no mall Id"
]
}
},
"type": "completion"
},
"brand_suggest": {
"context": {
"mallIdContext": {
"path": "mallId",
"default": [
"no mall Id"
]
}
},
"type": "completion"
},
"mallId": {
"type": "long"
},
"source": {
"type": "string"
},
"title": {
"type": "string"
}
}
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment