Created
March 24, 2011 12:49
-
-
Save wizidot/885001 to your computer and use it in GitHub Desktop.
size.
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
creation of the index : | |
curl -XPUT localhost:9200/places -d '{ | |
"settings" : { | |
"index" : { | |
"analysis" : { | |
"analyzer" : { | |
"default" : { | |
"type" : "custom", | |
"tokenizer" : "whitespace", | |
"filter" : [ | |
"standard", | |
"lowercase", | |
"snowball" | |
] | |
} | |
}, | |
"filter" : { | |
"snowball" : { | |
"type" : "snowball", | |
"language" : "French" | |
} | |
} | |
} | |
} | |
}, | |
"mappings": { | |
"place": { | |
"properties": { | |
"CP" : { | |
"type" : "integer", | |
"boost" : "2" | |
}, | |
"VILLE" : { | |
"type" : "multi_field", | |
"fields" : { | |
"VILLE" : { | |
"omit_term_freq_and_positions" : false, | |
"omit_norms" : false, | |
"store" : "yes", | |
"term_vector" : "no", | |
"type" : "string", | |
"index" : "analyzed", | |
"boost" : 2 | |
}, | |
"untouched" : { | |
"omit_term_freq_and_positions" : true, | |
"omit_norms" : true, | |
"store" : "yes", | |
"type" : "string", | |
"term_vector" : "no", | |
"index" : "not_analyzed" | |
} | |
} | |
}, | |
"PAYS" : { | |
"type" : "string", | |
"store" : "yes", | |
"index" : "not_analyzed" | |
}, | |
"ADRESSE": { | |
"type": "string", | |
"store": "yes", | |
"index": "no" | |
}, | |
"TEL": { | |
"type": "string", | |
"store": "yes", | |
"index": "no" | |
}, | |
"TELECOPIE": { | |
"type": "string", | |
"store": "yes", | |
"index": "no" | |
}, | |
"EMAIL": { | |
"type": "string", | |
"store": "yes", | |
"index": "no" | |
}, | |
"OPTOUT": { | |
"type": "boolean", | |
"index": "no", | |
"store": "yes", | |
"null_value": "0" | |
}, | |
"WEB": { | |
"type": "string", | |
"store": "yes", | |
"index": "no" | |
}, | |
"CODE_NAF": { | |
"type": "string", | |
"store": "yes", | |
"index": "no" | |
}, | |
"NAME": { | |
"type" : "multi_field", | |
"fields" : { | |
"NAME" : { | |
"omit_term_freq_and_positions" : false, | |
"omit_norms" : false, | |
"store" : "yes", | |
"term_vector" : "no", | |
"type" : "string", | |
"index" : "analyzed", | |
"boost" : 2 | |
}, | |
"untouched" : { | |
"omit_term_freq_and_positions" : true, | |
"omit_norms" : true, | |
"store" : "yes", | |
"type" : "string", | |
"term_vector" : "no", | |
"index" : "not_analyzed" | |
} | |
} | |
}, | |
"LIBELLE_NAF": { | |
"type" : "multi_field", | |
"fields" : { | |
"LIBELLE_NAF" : { | |
"omit_term_freq_and_positions" : false, | |
"omit_norms" : false, | |
"store" : "yes", | |
"term_vector" : "no", | |
"type" : "string", | |
"index" : "analyzed", | |
"boost" : 1 | |
}, | |
"untouched" : { | |
"omit_term_freq_and_positions" : true, | |
"omit_norms" : true, | |
"store" : "yes", | |
"type" : "string", | |
"term_vector" : "no", | |
"index" : "not_analyzed" | |
} | |
} | |
}, | |
"location" : { | |
"type" : "geo_point" | |
}, | |
"created": { | |
"type": "date", | |
"format" : "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd", | |
"store": "no" | |
}, | |
"modified": { | |
"type": "date", | |
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd", | |
"store": "no" | |
}, | |
"active": { | |
"type": "boolean", | |
"index": "no", | |
"store": "yes" | |
}, | |
"LEADID": { | |
"type": "string", | |
"store": "yes", | |
"index": "no" | |
}, | |
"CONTACTID": { | |
"type": "string", | |
"store": "yes", | |
"index": "no" | |
}, | |
"ACCOUNTID": { | |
"type": "string", | |
"store": "yes", | |
"index": "no" | |
}, | |
"SMOWNERID": { | |
"type": "string", | |
"store": "yes", | |
"index": "no" | |
}, | |
"cat1": { | |
"type" : "multi_field", | |
"fields" : { | |
"cat1" : { | |
"omit_term_freq_and_positions" : false, | |
"omit_norms" : false, | |
"store" : "yes", | |
"term_vector" : "no", | |
"type" : "string", | |
"index" : "analyzed", | |
"boost" : 2.3 | |
}, | |
"untouched" : { | |
"omit_term_freq_and_positions" : true, | |
"omit_norms" : true, | |
"store" : "yes", | |
"type" : "string", | |
"term_vector" : "no", | |
"index" : "not_analyzed" | |
} | |
} | |
}, | |
"cat2": { | |
"type" : "multi_field", | |
"fields" : { | |
"cat2" : { | |
"omit_term_freq_and_positions" : false, | |
"omit_norms" : false, | |
"store" : "yes", | |
"term_vector" : "no", | |
"type" : "string", | |
"index" : "analyzed", | |
"boost" : 2.2 | |
}, | |
"untouched" : { | |
"omit_term_freq_and_positions" : true, | |
"omit_norms" : true, | |
"store" : "yes", | |
"type" : "string", | |
"term_vector" : "no", | |
"index" : "not_analyzed" | |
} | |
} | |
}, | |
"cat3": { | |
"type" : "multi_field", | |
"fields" : { | |
"cat3" : { | |
"omit_term_freq_and_positions" : false, | |
"omit_norms" : false, | |
"store" : "yes", | |
"term_vector" : "no", | |
"type" : "string", | |
"index" : "analyzed", | |
"boost" : 2.1 | |
}, | |
"untouched" : { | |
"omit_term_freq_and_positions" : true, | |
"omit_norms" : true, | |
"store" : "yes", | |
"type" : "string", | |
"term_vector" : "no", | |
"index" : "not_analyzed" | |
} | |
} | |
}, | |
"RUBRIQUE_PROFESSIONNELLE": { | |
"type" : "multi_field", | |
"fields" : { | |
"RUBRIQUE_PROFESSIONNELLE" : { | |
"omit_term_freq_and_positions" : false, | |
"omit_norms" : false, | |
"store" : "yes", | |
"term_vector" : "no", | |
"type" : "string", | |
"index" : "analyzed", | |
"boost" : 1 | |
}, | |
"untouched" : { | |
"omit_term_freq_and_positions" : true, | |
"omit_norms" : true, | |
"store" : "yes", | |
"type" : "string", | |
"term_vector" : "no", | |
"index" : "not_analyzed" | |
} | |
} | |
} | |
} | |
} | |
} | |
}' | |
/******************** SOME DATA **/ | |
curl -XPUT 'http://localhost:9200/_bulk' -d '{"index" : {"_index" :"places","_type":"place","_id":"BrIbJ8YdTou0Rbwym-G3YA"}} | |
{"LEADID":"351877000000102025","SMOWNERID":"351877000000040003","NAME":"Renov Habitat 26","created":"2011-03-18 10:06:55","modified":"2011-03-18 12:09:40","ADRESSE":"quart Brunelle","VILLE":"EURRE","CP":"26400","PAYS":"france","OPTOUT":"false","location":"44.7398831,4.9809244","cat1":"Vente, pose, traitement de carrelages, dallages"} | |
{"index" : {"_index" :"places","_type":"place","_id":"Rg_lCU6xR1-SpIfpICYaFQ"}} | |
{"LEADID":"351877000000102021","SMOWNERID":"351877000000040003","NAME":"Freyssin TP","created":"2011-03-18 10:06:55","modified":"2011-03-18 12:09:41","ADRESSE":"quart Saxonne","VILLE":"EURRE","CP":"26400","PAYS":"france","OPTOUT":"false","location":"44.7591853,4.9887388","cat1":"Travaux publics"} | |
{"index" : {"_index" :"places","_type":"place","_id":"pW7F09lbT6mVyHOFBZhQAA"}} | |
{"LEADID":"351877000000102017","SMOWNERID":"351877000000040003","NAME":"Nowicki Pascal","created":"2011-03-18 10:06:55","modified":"2011-03-18 12:09:42","ADRESSE":"20 quart Laye","VILLE":"EURRE","CP":"26400","PAYS":"france","OPTOUT":"false","location":"44.757319,4.9936888","cat1":"Transport express national, international"} | |
{"index" : {"_index" :"places","_type":"place","_id":"JPk9-AE_Tj-8WR7NZf7G-Q"}} | |
{"LEADID":"351877000000102013","SMOWNERID":"351877000000040003","NAME":"Taxi Matthieu Faure","created":"2011-03-18 10:06:55","modified":"2011-03-18 12:09:43","ADRESSE":"Taxi de Bourdeaux quart Sauvionne","VILLE":"SAOU","CP":"26400","PAYS":"france","OPTOUT":"false","location":"44.6470371,5.0628521","cat1":"Taxis"} | |
{"index" : {"_index" :"places","_type":"place","_id":"_6ebBEgfRL-s6-5B3-fPUQ"}} | |
{"LEADID":"351877000000102007","SMOWNERID":"351877000000040003","NAME":"Aldi March\u00e9","created":"2011-03-18 10:06:54","modified":"2011-03-18 12:09:44","ADRESSE":"av Charles Armorin","VILLE":"CREST","CP":"26400","PAYS":"france","OPTOUT":"false","location":"44.7326269,5.0132015","cat1":"Supermarch\u00e9 et hypermarch\u00e9"} | |
{"index" : {"_index" :"places","_type":"place","_id":"8EjrBjpBSaetx_VASG_lcQ"}} | |
{"LEADID":"351877000000101991","SMOWNERID":"351877000000040003","NAME":"Golf de Sagnol","TELECOPIE":"0475415313","created":"2011-03-18 10:06:54","modified":"2011-03-18 12:09:47","ADRESSE":"quart sagnol","VILLE":"GIGORS ET LOZERON","CP":"26400","PAYS":"france","OPTOUT":"false","location":"44.8159447,5.1059542","cat1":"Restaurants"} | |
{"index" : {"_index" :"places","_type":"place","_id":"ftvJvn49RDS9nxFSheUpLw"}} | |
{"LEADID":"351877000000101987","SMOWNERID":"351877000000040003","NAME":"Brunache Alain","EMAIL":"a.brunache@orange.fr","created":"2011-03-18 10:06:54","modified":"2011-03-18 12:10:28","ADRESSE":"quart St Jean","VILLE":"AUTICHAMP","CP":"26400","PAYS":"france","OPTOUT":"false","location":"44.6822056,4.9646089","cat1":"Psychoth\u00e9rapeutes"} | |
{"index" : {"_index" :"places","_type":"place","_id":"lCHjLt41RamP8QRHZ9URBA"}} | |
{"LEADID":"351877000000101985","SMOWNERID":"351877000000040003","NAME":"AROLE PF","TELECOPIE":"04 75 25 85 34","created":"2011-03-18 10:06:54","modified":"2011-03-18 12:10:28","ADRESSE":"Quai Henri Latune","VILLE":"CREST","CP":"26400","PAYS":"france","OPTOUT":"false","RUBRIQUE_PROFESSIONNELLE":"Services fun\u00e9raires","LIBELLE_NAF":"POMPE FUNEBRE INHUMATION CREMATION","CODE_NAF":"9603Z","location":"44.7279814,5.0189707","cat1":"Pompes fun\u00e8bres"} | |
{"index" : {"_index" :"places","_type":"place","_id":"kptmUm5AT7KVyPtiILZhRA"}} | |
{"LEADID":"351877000000101979","SMOWNERID":"351877000000040003","NAME":"TP du Lauzun","created":"2011-03-18 10:06:54","modified":"2011-03-18 12:10:29","ADRESSE":"rte de pas de Lauzun","VILLE":"AOUSTE SUR SYE","CP":"26400","PAYS":"france","OPTOUT":"false","location":"44.7156168,5.0573575","cat1":"Paysagistes"} | |
{"index" : {"_index" :"places","_type":"place","_id":"vCm02AudRAmrQMSOEjIQBw"}} | |
{"LEADID":"351877000000101977","SMOWNERID":"351877000000040003","NAME":"MPF (Mouvement pour la France","created":"2011-03-18 10:06:54","modified":"2011-03-18 12:10:29","ADRESSE":"imp Pavillon","VILLE":"MONTMEYRAN","CP":"26120","PAYS":"france","OPTOUT":"false","location":"44.8654663,4.9510772","cat1":"Partis politiques"} | |
' | |
/***************** My query *********************************************** / | |
curl -XGET http://localhost:9200/places/place/_search -d ' | |
{ | |
"from":0, | |
"size":10, | |
"query": { | |
"filtered" : { | |
"query":{ | |
"match_all" : {} | |
}, | |
"filter" : { | |
"or" : [ | |
{ | |
"term" : { "VILLE" : "crest" } | |
}, | |
{ | |
"term" : { "VILLE" : "allex" } | |
}, | |
{ | |
"term" : { "VILLE" : "ambonil" } | |
}, | |
{ | |
"term" : { "VILLE" : "aouste sur Sye" } | |
}, | |
{ | |
"term" : { "VILLE" : "aubenasson" } | |
}, | |
{ | |
"term" : { "VILLE" : "autichamp" } | |
}, | |
{ | |
"term" : { "VILLE" : "beaufort sur Gervanne" } | |
}, | |
{ | |
"term" : { "VILLE" : "chabrillan" } | |
}, | |
{ | |
"term" : { "VILLE" : "beaufort sur gervanne" } | |
}, | |
{ | |
"term" : { "VILLE" : "mirabel et blacons" } | |
}, | |
{ | |
"term" : { "VILLE" : "chastel arnaud" } | |
}, | |
{ | |
"term" : { "VILLE" : "cobonne" } | |
}, | |
{ | |
"term" : { "VILLE" : "espenel" } | |
}, | |
{ | |
"term" : { "VILLE" : "eurre" } | |
}, | |
{ | |
"term" : { "VILLE" : "francillon sur roubion" } | |
}, | |
{ | |
"term" : { "VILLE" : "gigors et lozeron" } | |
}, | |
{ | |
"term" : { "VILLE" : "grane" } | |
}, | |
{ | |
"term" : { "VILLE" : "la baume cornillane" } | |
}, | |
{ | |
"term" : { "VILLE" : "la roche sur grane" } | |
} | |
] | |
} | |
} | |
}, | |
"facets" : { | |
"category" : { | |
"terms" : { | |
"field" : "cat1.untouched", | |
"size" : 3 | |
}, | |
"global":false | |
}, | |
"locations":{ | |
"terms" : { | |
"field" : "VILLE.untouched", | |
"size" : 3 | |
}, | |
"global":false | |
} | |
} | |
}' | |
/************** RESULT **/ | |
Inside this result we can see that a majority of docs are set for the VILLE = CREST, I wouldlike to balance results between terms, | |
ie 24 per VILLE... | |
{ | |
"took" : 2, | |
"timed_out" : false, | |
"_shards" : { | |
"total" : 5, | |
"successful" : 5, | |
"failed" : 0 | |
}, | |
"hits" : { | |
"total" : 381, | |
"max_score" : 1.0, | |
"hits" : [ { | |
"_index" : "places", | |
"_type" : "place", | |
"_id" : "_6ebBEgfRL-s6-5B3-fPUQ", | |
"_score" : 1.0, "_source" : {"LEADID":"351877000000102007","SMOWNERID":"351877000000040003","NAME":"Aldi March\u00e9","created":"2011-03-18 10:06:54","modified":"2011-03-18 12:09:44","ADRESSE":"av Charles Armorin","VILLE":"CREST","CP":"26400","PAYS":"france","OPTOUT":"false","location":"44.7326269,5.0132015","cat1":"Supermarch\u00e9 et hypermarch\u00e9"} | |
}, { | |
"_index" : "places", | |
"_type" : "place", | |
"_id" : "ftvJvn49RDS9nxFSheUpLw", | |
"_score" : 1.0, "_source" : {"LEADID":"351877000000101987","SMOWNERID":"351877000000040003","NAME":"Brunache Alain","EMAIL":"a.brunache@orange.fr","created":"2011-03-18 10:06:54","modified":"2011-03-18 12:10:28","ADRESSE":"quart St Jean","VILLE":"AUTICHAMP","CP":"26400","PAYS":"france","OPTOUT":"false","location":"44.6822056,4.9646089","cat1":"Psychoth\u00e9rapeutes"} | |
}, { | |
"_index" : "places", | |
"_type" : "place", | |
"_id" : "lCHjLt41RamP8QRHZ9URBA", | |
"_score" : 1.0, "_source" : {"LEADID":"351877000000101985","SMOWNERID":"351877000000040003","NAME":"AROLE PF","TELECOPIE":"04 75 25 85 34","created":"2011-03-18 10:06:54","modified":"2011-03-18 12:10:28","ADRESSE":"Quai Henri Latune","VILLE":"CREST","CP":"26400","PAYS":"france","OPTOUT":"false","RUBRIQUE_PROFESSIONNELLE":"Services fun\u00e9raires","LIBELLE_NAF":"POMPE FUNEBRE INHUMATION CREMATION","CODE_NAF":"9603Z","location":"44.7279814,5.0189707","cat1":"Pompes fun\u00e8bres"} | |
}, { | |
"_index" : "places", | |
"_type" : "place", | |
"_id" : "Vm94_jYJSPybz-tEjuENDA", | |
"_score" : 1.0, "_source" : {"LEADID":"351877000000101963","SMOWNERID":"351877000000040003","NAME":"LES ECUREUILS SARL","created":"2011-03-18 10:06:54","modified":"2011-03-18 12:01:54","ADRESSE":"LES JARDINS DE ST LOUIS 13 AV. AGIROND ENTREE 11","VILLE":"CREST","CP":"26400","PAYS":"france","OPTOUT":"false","RUBRIQUE_PROFESSIONNELLE":"Activit\u00e9s des marchands de biens immobiliers","CODE_NAF":"6810Z","location":"44.7294644,5.0253925","cat1":"marchands de biens"} | |
}, { | |
"_index" : "places", | |
"_type" : "place", | |
"_id" : "mDweALkUT0WLjVnJzo1Jnw", | |
"_score" : 1.0, "_source" : {"LEADID":"351877000000101961","SMOWNERID":"351877000000040003","NAME":"SES Ribert Siman","created":"2011-03-18 10:06:54","modified":"2011-03-18 12:01:55","ADRESSE":"La Croze","VILLE":"CHABRILLAN","CP":"26400","PAYS":"france","OPTOUT":"false","location":"44.7160045,4.9433303","cat1":"Maintenance industrielle"} | |
}, { | |
"_index" : "places", | |
"_type" : "place", | |
"_id" : "X9FFa288QEOvCbut-_Voqg", | |
"_score" : 1.0, "_source" : {"LEADID":"351877000000101957","SMOWNERID":"351877000000040003","NAME":"Loc-aventure-drome","created":"2011-03-18 10:06:53","modified":"2011-03-18 12:01:55","ADRESSE":"mont\u00e9e Barbey\u00e8re","VILLE":"CREST","CP":"26400","PAYS":"france","OPTOUT":"false","location":"44.7294731,5.0266981","cat1":"Location de caravanes, mobile homes"} | |
}, { | |
"_index" : "places", | |
"_type" : "place", | |
"_id" : "usyOhP8-RO-1_al08PYnuw", | |
"_score" : 1.0, "_source" : {"LEADID":"351877000000101879","SMOWNERID":"351877000000040003","NAME":"La Toupie","created":"2011-03-18 10:06:52","modified":"2011-03-18 12:02:10","ADRESSE":"5 av F\u00e9lix Rozier","VILLE":"CREST","CP":"26400","PAYS":"france","OPTOUT":"false","location":"44.7344504,5.0111796","cat1":"\u00c9b\u00e9nisterie d'art, restauration de meubles"} | |
}, { | |
"_index" : "places", | |
"_type" : "place", | |
"_id" : "cThgxXfoRc64dYRQLsuSkQ", | |
"_score" : 1.0, "_source" : {"LEADID":"351877000000101873","SMOWNERID":"351877000000040003","NAME":"Delaunay Tabaski","created":"2011-03-18 10:06:52","modified":"2011-03-18 12:02:11","ADRESSE":"18 quai Maurice Faure","VILLE":"CREST","CP":"26400","PAYS":"france","OPTOUT":"false","location":"44.7277908,5.0209658","cat1":"D\u00e9coration (magasins)"} | |
}, { | |
"_index" : "places", | |
"_type" : "place", | |
"_id" : "lq25HFa_R1iCy8zXyxfpmQ", | |
"_score" : 1.0, "_source" : {"LEADID":"351877000000101847","SMOWNERID":"351877000000040003","NAME":"LES FILMS A CARREAUX","created":"2011-03-18 10:06:51","modified":"2011-03-18 10:06:51","ADRESSE":"6 Rue du Clocher","VILLE":"CREST","CP":"26400","PAYS":"france","OPTOUT":"false","RUBRIQUE_PROFESSIONNELLE":"Production de films pour le cin\u00e9ma","CODE_NAF":"5911C","location":"44.7295444,5.0236595","cat1":"Cin\u00e9ma : production et r\u00e9alisation"} | |
}, { | |
"_index" : "places", | |
"_type" : "place", | |
"_id" : "BwiksnxhSaOvP1FHP7Sm0w", | |
"_score" : 1.0, "_source" : {"LEADID":"351877000000101755","SMOWNERID":"351877000000040003","NAME":"Pascal (SARL)","created":"2011-03-18 10:06:50","modified":"2011-03-18 12:10:01","ADRESSE":"79 r H\u00f4tel de Ville","VILLE":"CREST","CP":"26400","PAYS":"france","OPTOUT":"false","location":"44.7293568,5.0198038","cat1":"Boucherie, boucherie-charcuterie"} | |
} ] | |
}, | |
"facets" : { | |
"category" : { | |
"_type" : "terms", | |
"missing" : 0, | |
"terms" : [ { | |
"term" : "Entreprises d'électricité générale", | |
"count" : 10 | |
}, { | |
"term" : "Médecins : médecine générale", | |
"count" : 7 | |
}, { | |
"term" : "Assurances : agents généraux", | |
"count" : 7 | |
} ] | |
}, | |
"locations" : { | |
"_type" : "terms", | |
"missing" : 0, | |
"terms" : [ { | |
"term" : "CREST", | |
"count" : 326 | |
}, { | |
"term" : "CHABRILLAN", | |
"count" : 19 | |
}, { | |
"term" : "ESPENEL", | |
"count" : 12 | |
} ] | |
} | |
} | |
} |
lukas-vlcek
commented
Mar 24, 2011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment