Skip to content

Instantly share code, notes, and snippets.

Created March 1, 2012 14:09
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 anonymous/1950044 to your computer and use it in GitHub Desktop.
Save anonymous/1950044 to your computer and use it in GitHub Desktop.
doc+query sample
{
"_index": "annoncespoc_test2",
"_type": "annonces",
"_id": "49106380",
"_score": 1.0,
"_source": {
"$id": "1",
"si_dernieretage": false,
"idpublication": [448661],
"idtypepublication": [11],
"idannonce": 49106380,
"idagence": 85387,
"refannonce": "63512",
"cp": "14129",
"ville": "Berlin",
"idpays": 276,
"idtypebien": 8,
"idtypetransaction": 1,
"dt_crea": "2011-12-22T14:26:00",
"dt_maj": "2011-12-22T14:27:00",
"si_exclusif": false,
"si_coupdecoeur": false,
"ts": "AAAAHqhS0pY=",
"si_handicape": false,
"si_promo": false,
"nb_photos": 5,
"nb_360": 0,
"indice_qualite_tri": 0,
"nb_videos": 0,
"nb_photos_all": 0,
"nb_360_all": 0,
"nb_videos_all": 0,
"rankVisuel": 0,
"si_webvisium_magic": false,
"si_ismh": false,
"isAttentePostTraiter": false,
"px_loyer": 7.0,
"si_loyer_ht": false,
"si_loyer_cc": true,
"si_entretien": false,
"si_cuisine": false,
"si_securite": false,
"siEtudiant": false,
"idttb": 1,
"pxz": 7.0,
"siSL": 0,
"idpubis": 448661,
"siIS": 1,
"dep": 0,
"dep2": 0,
"siAGB": 0,
"siBD": 0,
"idpubsln": -1,
"siSLN": 1,
"idpubcmi": -1,
"siCMI": 1
}
}
{
"query": {
"custom_filters_score": {
"score_mode": "total",
"query": {
"filtered": {
"query": {
"match_all": {
}
},
"filter": {
"and": {
"filters": [{
"term": {
"siSL": "1"
}
},
{
"terms": {
"idtypetransaction": ["1",
"11"]
}
},
{
"or": {
"filters": [{
"or": {
"filters": [{
"range": {
"codeinsee": {
"from": "890000",
"to": "899999"
}
}
}]
}
}]
}
},
{
"terms": {
"idpays": ["250"]
}
},
{
"or": {
"filters": [{
"term": {
"si_meuble": "false"
}
},
{
"missing": {
"field": "si_meuble"
}
}]
}
}]
}
}
}
},
"filters": [{
"filter": {
"exists": {
"field": "nb_pieces"
}
},
"boost": 1
},
{
"filter": {
"exists": {
"field": "si_meuble"
}
},
"boost": 1
},
{
"filter": {
"or": {
"filters": [{
"and": {
"filters": [{
"exists": {
"field": "si_loyer_cc"
}
},
{
"term": {
"si_loyer_cc": "true"
}
}]
}
},
{
"and": {
"filters": [{
"exists": {
"field": "px_charges"
}
},
{
"range": {
"px_charges": {
"from": "1"
}
}
}]
}
}]
}
},
"boost": 1
},
{
"filter": {
"not": {
"and": {
"filters": [{
"exists": {
"field": "nb_pieces"
}
},
{
"exists": {
"field": "si_meuble"
}
},
{
"or": {
"filters": [{
"and": {
"filters": [{
"exists": {
"field": "si_loyer_cc"
}
},
{
"term": {
"si_loyer_cc": "true"
}
}]
}
},
{
"and": {
"filters": [{
"exists": {
"field": "px_charges"
}
},
{
"range": {
"px_charges": {
"from": "1"
}
}
}]
}
}]
}
}]
}
}
},
"boost": 0
}]
}
},
"size": 200,
"fields": ["idannonce",
"idpublication",
"idtypepublication"],
"filter": {
"and": {
"filters": [{
"or": {
"filters": [{
"terms": {
"nb_pieces": ["3"]
}
}]
}
},
{
"or": {
"filters": [{
"terms": {
"nb_chambres": ["2"]
}
}]
}
}]
}
},
"sort": [{
"_score": "desc"
},
{
"_script": {
"script": "if (_source.si_loyer_cc == true || _source.px_charges == null) { return _source.px_loyer; } else { return _source.px_loyer + _source.px_charges; }",
"type": "number",
"order": "asc"
}
},
{
"indice_qualite_tri": "desc"
},
{
"idannonce": "asc"
}],
"facets": {
"nb_pieces": {
"terms": {
"field": "nb_pieces"
},
"facet_filter": {
"and": {
"filters": [{
"or": {
"filters": [{
"terms": {
"nb_pieces": ["3"]
}
}]
}
}]
}
}
},
"nb_chambres": {
"terms": {
"field": "nb_chambres"
},
"facet_filter": {
"and": {
"filters": [{
"or": {
"filters": [{
"terms": {
"nb_pieces": ["3"]
}
}]
}
}]
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment