Created
December 11, 2013 15:36
-
-
Save anonymous/7912536 to your computer and use it in GitHub Desktop.
elasticSearch creatin d'index et ajout de document
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
# Delete the index `test` | |
#curl -XDELETE 'http://localhost:9200/test' ; echo | |
# Create the index `test` | |
curl -XPUT 'http://localhost:9200/test2' -d '{ | |
"settings" : { | |
"index" : { | |
"number_of_shards" : 3, | |
"number_of_replicas" : 2, | |
"analysis" : { | |
"analyzer" : { | |
"myAnalyser" : { | |
"type":"custom", | |
"tokenizer" : "standard", | |
"filter" : ["asciifolding", "lowercase","myElision", "myStop" ] | |
} | |
}, | |
"filter" : { | |
"myStop" : { | |
"type" : "stop", | |
"stopwords" : ["de", "van"] | |
}, | |
"myElision" : { | |
"type" : "elision", | |
"articles" : ["a", "b"] | |
} | |
} | |
} | |
} | |
} | |
}' ; echo | |
# Wait for yellow | |
curl -XGET 'http://localhost:9200/_cluster/health?wait_for_status=yellow' ; echo | |
# Testing Shingles | |
# http://www.elasticsearch.org/guide/reference/index-modules/analysis/shingle-tokenfilter/ | |
# analyze it | |
#curl -XPOST 'http://localhost:9200/test/_analyze?analyzer=myAnalyser&pretty' -d 'Espérance' ; echo | |
#curl -XPOST 'http://localhost:9200/test/_analyze?analyzer=my_shingle&pretty' -d 'van de jesis' ; echo | |
#curl -XPOST 'http://localhost:9200/test/_analyze?analyzer=my_fr_shingle&pretty' -d 'pomme de terre' ; echo | |
# Ajout du mapping | |
curl -s -XPUT 'http://localhost:9200/test2/personne2/_mapping' -d '{ | |
"personne2" : { | |
"_all" : {"enabled" : true}, | |
"_id" : { | |
"path" : "_id" | |
}, | |
"properties": { | |
"nom": { | |
"type" : "string", | |
"path" : "nom", | |
"analyzer" : "myAnalyser" | |
}, | |
"dspt_nom_conjoint": { | |
"type" : "string", | |
"path" : "dspt_nom_conjoint", | |
"analyzer" : "myAnalyser" | |
}, | |
"dt_naiss": { | |
"type" : "string", | |
"path" : "dt_naiss", | |
"analyzer" : "myAnalyser" | |
} | |
,"prenoms":{"properties":{"prenom":{"type":"string", | |
"analyzer" : "myAnalyser" | |
} | |
} | |
} | |
} | |
} | |
}' ;echo | |
#ajout d'un document | |
curl -XPOST 'http://localhost:9200/test2/personne2/' -d '{ | |
"_index" : "test2", | |
"_type" : "personne2", | |
"_id" : "1", | |
"nom": "Espérance", | |
"dspt_nom_conjoint": "Jaquot", | |
"dt_naiss": "01011956", | |
"prenoms.prenom": "eric" | |
}' ;echo | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment