Last active
January 5, 2019 12:38
-
-
Save 2arunpmohan/c31298870c36b98ace37a78ba7df6b60 to your computer and use it in GitHub Desktop.
bash scripts for "suggest" mapping
example of suggest implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" | |
} | |
} | |
} | |
} | |
} | |
} | |
}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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