Skip to content

Instantly share code, notes, and snippets.

@dadoonet
Created December 14, 2011 16:30
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 dadoonet/1477309 to your computer and use it in GitHub Desktop.
Save dadoonet/1477309 to your computer and use it in GitHub Desktop.
Create Mappings
#!/bin/bash
PROGNAME=`basename $0`
ESINDEXNAME="myindexname"
#
# Helper to complain.
#
warn() {
echo "${PROGNAME}: $*"
}
#
# Helper to puke.
#
die() {
warn $*
exit 1
}
usage ()
{
LSTJSON=`ls *.json`
echo "Usage : createMapping.sh typename (without .json extension filename)"
echo " E.g.: createMapping.sh Dossier"
echo "Current known mappings :"
echo "$LSTJSON"
}
if [ $# -ne 1 ]
then
usage
exit 2
fi
ESTYPE="$1"
ESJSONFILE="$ESTYPE.json"
if [ ! -f "$ESJSONFILE" ]; then
die "Missing file: $ESJSONFILE"
fi
# DELETE Type
echo "Delete $ESTYPE from $ESINDEXNAME : "
ESDELETE=`curl -s -XDELETE http://localhost:9200/$ESINDEXNAME/$ESTYPE/`
echo "$ESDELETE"
# Create Mapping for Type
echo "Create mapping for type $ESTYPE in $ESINDEXNAME : "
ESCREATE=`curl -s -XPUT http://localhost:9200/$ESINDEXNAME/$ESTYPE/_mapping -d @$ESJSONFILE`
echo "$ESCREATE"
exit 0
{
"LigneRegistre": {
"properties": {
"personne": {
"dynamic": "true",
"properties": {
"PersonneMorale": {
"dynamic": "true",
"properties": {
"fax": {
"analyzer": "key_lowercase",
"type": "string"
},
"rue": {
"analyzer": "key_lowercase",
"boost": 1.5,
"type": "string"
},
"email": {
"analyzer": "key_lowercase",
"type": "string"
},
"codePostal": {
"analyzer": "key_lowercase",
"type": "string"
},
"tel": {
"analyzer": "key_lowercase",
"type": "string"
},
"ville": {
"analyzer": "key_lowercase",
"type": "string"
},
"nom": {
"analyzer": "key_lowercase",
"type": "string"
},
"personnesIdentifiantsForES": {
"dynamic": "true",
"properties": {
"type": {
"analyzer": "key_lowercase",
"type": "string"
},
"identifiant": {
"analyzer": "key_lowercase",
"type": "string"
}
}
}
}
},
"PersonnePhysique": {
"dynamic": "true",
"properties": {
"prenom": {
"analyzer": "key_lowercase",
"type": "string"
},
"fax": {
"analyzer": "key_lowercase",
"type": "string"
},
"rue": {
"analyzer": "key_lowercase",
"type": "string"
},
"email": {
"analyzer": "key_lowercase",
"type": "string"
},
"codePostal": {
"analyzer": "key_lowercase",
"type": "string"
},
"tel": {
"analyzer": "key_lowercase",
"type": "string"
},
"ville": {
"analyzer": "key_lowercase",
"type": "string"
},
"nom": {
"analyzer": "key_lowercase",
"type": "string"
},
"personnesIdentifiantsForES": {
"dynamic": "true",
"properties": {
"type": {
"analyzer": "key_lowercase",
"type": "string"
},
"identifiant": {
"analyzer": "key_lowercase",
"type": "string"
}
}
}
}
}
}
},
"horodatage": {
"type": "long"
},
"agent": {
"type": "string"
},
"refSupport": {
"analyzer": "key_lowercase",
"type": "string"
},
"remarques": {
"type": "string"
},
"montantDette": {
"type": "long"
},
"lrserviceES": {
"analyzer": "key_lowercase",
"type": "string"
},
"constatations": {
"type": "string"
},
"oraleOuEcriteES": {
"type": "string"
},
"montantDetteFinal": {
"type": "long"
},
"prenomRepresentant": {
"type": "string"
},
"montantTaxeNationaleFinal": {
"type": "long"
},
"nomRepresentant": {
"type": "string"
},
"identifiantDossier": {
"analyzer": "key_lowercase",
"type": "string"
},
"montantTaxeNationale": {
"type": "long"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment