Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7581831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:17:24+00:00 2026-05-30T18:17:24+00:00

Lets say I have the following mapping: site: { properties: { title: { type:

  • 0

Lets say I have the following mapping:

"site": {
  "properties": {
    "title":       { "type": "string" },
    "description": { "type": "string" },
    "category":    { "type": "string" },
    "tags":        { "type": "array" },
    "point":       { "type": "geo_point" }
    "localities":  { 
      type: 'nested',
      properties: {
        "title":       { "type": "string" },
        "description": { "type": "string" },
        "point":       { "type": "geo_point" }
      }
    }
  }
}

I’m then doing an “_geo_distance” sort on the parent document and am able to sort the documents on “site.point”. However I would also like the nested localities to be sorted by “_geo_distance”, inside the parent document.

Is this possible? If so, how?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:17:25+00:00Added an answer on May 30, 2026 at 6:17 pm

    Unfortunately, no (at least not yet).

    A query in ElasticSearch just identifies which documents match the query, and how well they match.

    To understand what nested documents are useful for, consider this example:

    {
        "title":    "My post",
        "body":     "Text in my body...",
        "followers": [
            {
                "name":     "Joe",
                "status":   "active"
            },
            {
                "name":     "Mary",
                "status":   "pending"
            },
        ]
    }        
    

    The above JSON, once indexed in ES, is functionally equivalent to the following. Note how the followers field has been flattened:

    {
        "title":            "My post",
        "body":             "Text in my body...",
        "followers.name":   ["Joe","Mary"],
        "followers.status": ["active","pending"]
    }        
    

    A search for: followers with status == active and name == Mary would match this document… incorrectly.

    Nested fields allow us to work around this limitation. If the followers field is declared to be of type nested instead of type object then its contents are created as a separate (invisible) sub-document internally. That means that we can use a nested query or nested filter to query these nested documents as individual docs.

    However, the output from the nested query/filter clauses only tells us if the main doc matches, and how well it matches. It doesn’t even tell us which of the nested docs matched. To figure that out, we’d have to write code in our application to check each of the nested docs against our search criteria.

    There are a few open issues requesting the addition of these features, but it is not an easy problem to solve.

    The only way to achieve what you want is to index your sub-docs as separate documents, and to query and sort them independently. It may be useful to establish a parent-child relationship between the main doc and these separate sub-docs. (see parent-type mapping, the Parent & Child section of the index api docs, and the top-children and has-child queries.

    Also, an ES user has mailed the list about a new has_parent filter that they are currently working on in a fork. However, this is not available in the main ES repo yet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have the following array: Array ( [1284487200] => Array ( [title]
Lets say I have the following mapping: <hibernate-mapping package=mypackage> <class name=User table=user> <id name=id
Lets say I have the following code: abstract class Animal case class Dog(name:String) extends
Lets say I have the following array in JavaScript: var skins = new Array('Light',
Lets say I have a following structures in c++ struct Fruit { std::string name,
Lets say i have following class public class abc { int id; string name;
lets say we have the following array $myArray = array( foo => value1 ,
Let's say I have the following class Book class Book{ String author; String title;
Lets say we have the following two class definitions. #include <iostream> #include <array> class
Lets say I have the following code public static string GetXMLValue() { XDocument settingsFile

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.