Last active
August 29, 2015 14:20
-
-
Save jiri-jagos/4c9599a0b1ec87d2669e to your computer and use it in GitHub Desktop.
Is filtering elastichsearch result item nested fields (by e.g. geolocation) possible?
This file contains 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
### MAPPING ### | |
elastic_company_document_mapping: | |
testing: | |
type: 'boolean' | |
type: | |
type: 'string' | |
analyzer: 'standard' | |
fields: | |
folded: | |
type: 'string' | |
analyzer: 'sa_folding' | |
name: | |
type: 'string' | |
analyzer: 'standard' | |
fields: | |
orig: | |
type: 'string' | |
index: 'not_analyzed' | |
folded: | |
type: 'string' | |
analyzer: 'sa_folding' | |
short_description: | |
type: 'string' | |
analyzer: 'standard' | |
fields: | |
folded: | |
type: 'string' | |
analyzer: 'german' | |
description: | |
type: 'string' | |
analyzer: 'standard' | |
fields: | |
folded: | |
type: 'string' | |
analyzer: 'german' | |
locations: | |
type: 'nested' | |
properties: | |
city: | |
type: 'string' | |
analyzer: 'standard' | |
fields: | |
folded: | |
type: 'string' | |
analyzer: 'sa_folding' | |
street: | |
type: 'string' | |
analyzer: 'standard' | |
fields: | |
folded: | |
type: 'string' | |
analyzer: 'sa_folding' | |
pin: | |
lat_lon: true | |
type: geo_point | |
projects: | |
type: 'object' | |
properties: | |
project_name: | |
type: 'string' | |
analyzer: 'standard' | |
fields: | |
folded: | |
type: 'string' | |
analyzer: 'sa_folding' | |
project_description: | |
type: 'string' | |
analyzer: 'standard' | |
fields: | |
folded: | |
type: 'string' | |
analyzer: 'german' | |
project_segment: | |
type: 'string' | |
analyzer: 'standard' | |
fields: | |
folded: | |
type: 'string' | |
analyzer: 'sa_folding' | |
executed_activities_text: | |
type: 'string' | |
analyzer: 'standard' | |
fields: | |
folded: | |
type: 'string' | |
analyzer: 'german' | |
location: | |
properties: | |
city: | |
type: 'string' | |
analyzer: 'standard' | |
fields: | |
folded: | |
type: 'string' | |
analyzer: 'sa_folding' | |
street: | |
type: 'string' | |
analyzer: 'standard' | |
fields: | |
folded: | |
type: 'string' | |
analyzer: 'sa_folding' | |
pin: | |
lat_lon: true | |
type: geo_point | |
trades: | |
type: 'object' | |
properties: | |
package: | |
type: 'string' | |
analyzer: 'standard' | |
fields: | |
folded: | |
type: 'string' | |
analyzer: 'sa_folding' | |
trades: | |
type: 'string' | |
index_name: 'trade' | |
analyzer: 'standard' | |
fields: | |
folded: | |
type: 'string' | |
analyzer: 'sa_folding' | |
#### .... |
This file contains 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
{ | |
"_index": "prod", | |
"_type": "company", | |
"_id": "194228", | |
"_score": 1, | |
"_source": { | |
"id": "194228", | |
"name": "pbr Planungsbüro Rohling AG Architekten und Ingenieure", | |
"slug": "pbr-planungsburo-rohling-ag-architekten-und-ingenieure", | |
"testing": "0", | |
"employees_craft_total": null, | |
"employees_tech_total": null, | |
"short_description": "Gesamtplanung von Gebäuden mit hohem gestalterischen und technischen Anspruch für öffentliche Hand und Privatwirtschaft", | |
"description": "Planung von Laborgebäuden, Schwimmbädern, Rechenzentren, Krankenhäusern, Logistikimmobilien, Produktionsstätten für Automobil-, chemische, pharmazeutische und Lebensmittelindustrie, Bildungseinrichtungen, Hotels und Wohnanlagen, Großküchen und Mensen / Betriebsrestaurants", | |
"funding_year": "1960", | |
"action_radius": "eu_wide", | |
"action_radius_distance": null, | |
"completeness": "100", | |
"type": "Gesamtplaner", | |
"projects": [ // .... | |
], | |
"locations": [ | |
{ | |
"street": "Albert-Einstein-Straße 2", | |
"zip_code": "49076", | |
"city": "Osnabrück", | |
"pin": { | |
"lat": 52.335129, | |
"lon": 8.070955 | |
} | |
} | |
, | |
{ | |
"street": "Stralauer Platz 34", | |
"zip_code": "10243", | |
"city": "Berlin", | |
"pin": { | |
"lat": 52.50926, | |
"lon": 13.43212 | |
} | |
} | |
, | |
{ | |
"street": "Campestraße 7", | |
"zip_code": "38102", | |
"city": "Braunschweig", | |
"pin": { | |
"lat": 52.255762, | |
"lon": 10.53015 | |
} | |
} | |
, | |
{ | |
"street": "Zimmerstraße 15a", | |
"zip_code": "40215", | |
"city": "Düsseldorf", | |
"pin": { | |
"lat": 51.20981, | |
"lon": 6.78105 | |
} | |
} | |
, | |
{ | |
"street": "Fürstenbergerstraße 3-9", | |
"zip_code": "60322", | |
"city": "Frankfurt am Main", | |
"pin": { | |
"lat": 50.125843, | |
"lon": 8.681219 | |
} | |
} | |
, | |
{ | |
"street": "Dornbusch 2", | |
"zip_code": "20095", | |
"city": "Hamburg", | |
"pin": { | |
"lat": 53.5492, | |
"lon": 9.99398 | |
} | |
} | |
, | |
{ | |
"street": "Rathenaustraße 11", | |
"zip_code": "07745", | |
"city": "Jena", | |
"pin": { | |
"lat": 50.92307, | |
"lon": 11.58018 | |
} | |
} | |
, | |
{ | |
"street": "Friedrich-Ebert-Straße 62", | |
"zip_code": "39114", | |
"city": "Magdeburg", | |
"pin": { | |
"lat": 52.12445, | |
"lon": 11.66626 | |
} | |
} | |
, | |
{ | |
"street": "Kirchheimer Straße 64a", | |
"zip_code": "70619", | |
"city": "Stuttgart", | |
"pin": { | |
"lat": 48.74426, | |
"lon": 9.21277 | |
} | |
} | |
, | |
{ | |
"street": "Office 302; 22nd Line of Wassiljewskij Ostrov, 3; 199106 St. Petersburg, Russische Föderation", | |
"zip_code": null, | |
"city": "St. Petersburg, Russische Föderation", | |
"longitude": null, | |
"latitude": null | |
} | |
], | |
"certificates": [ | |
"iso9001" | |
], | |
}, | |
"sort": [ | |
100 | |
, | |
1 | |
] | |
} |
This file contains 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
{ | |
"query": { | |
"bool": { | |
"must": [ | |
{ | |
"bool": { | |
"must": [ | |
{ | |
"filtered": { | |
"query": { | |
"match_all": {} | |
}, | |
"filter": { | |
"nested": { | |
"path": "locations", | |
"filter": { | |
"geo_distance": { | |
"distance": "5km", | |
"locations.pin": { | |
"lat": 52.129005, | |
"lon": 11.620906 | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
] | |
} | |
} | |
] | |
} | |
}, | |
"from": 0, | |
"size": 50, | |
"sort": [ | |
{ | |
"completeness": "desc" | |
}, | |
{ | |
"_score": "desc" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment