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 6757291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:37:53+00:00 2026-05-26T13:37:53+00:00

Consider a very simple model where we have locations and each location can have

  • 0

Consider a very simple model where we have locations and each location can have zero or more events. A location would have properties such as name, description and geo point data (lon/lat). An event should be attached to one location (its parent) and should have a name and description.

{
    "location" : {
        "properties": {
            "name": { "type": "string", "boost": 2.0, "analyzer": "snowball" },
            "description": { "type": "string", "analyzer": "snowball" },
            "geo": { "type": "geo_point" },
            "exhibits": {
                "type": "nested",
                "properties": {
                    "name": { "type": "string", "boost": 2.0, "analyzer": "snowball" },
                    "description": { "type": "string", "analyzer": "snowball" }
                }
            }
        }
    }
}

What I want to be able to do, is to query for the child documents (events) performing a full text search on their names and descriptions. I would like to get the matching events back and be able to also get their parent location’s name. I would also like to narrow down the result set by location’s coordinates. I don’t want to get any events that do not match the query. Is that possible in Elastic Search? What types of queries should I use?

I have tried putting events as an array property under location (see above) and using the nested query but it does not return the kind of results I want (I think it returns the whole location, including all events, even the ones that do not match my query). I have tried putting events into a separate index (mapping?) providing the _parent property and then performing the top_children query on locations, but I don’t get any results.

{
    "exhibit": {
        "_parent": { "type": "locations" },
        "properties": {
            "name": { "type": "string", "boost": 2.0, "analyzer": "snowball" },
            "description": { "type": "string", "analyzer": "snowball" }
        }
    }
}

Could anyone shed some light? I don’t know where to begin…

  • 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-26T13:37:54+00:00Added an answer on May 26, 2026 at 1:37 pm

    Here’s the working solution to my problem, perhaps it will be useful to somebody.

    Location mapping:

    {
        "location" : {
            "properties": {
                "name": { "type": "string", "boost": 2.0, "analyzer": "snowball" },
                "description": { "type": "string", "analyzer": "snowball" },
                "geo": { "type": "geo_point" }
            }
        }
    }
    

    Exhibit mapping:

    {
        "exhibit": {
            "_parent": { "type": "locations" },
            "properties": {
                "name": { "type": "string", "boost": 2.0, "analyzer": "snowball" },
                "description": { "type": "string", "analyzer": "snowball" }
            }
        }
    }
    

    Query:

    {
        "fields": [ "_parent", "name", "_source" ],
        "query": {
            "bool": {
                "should": [ 
                    { "text": { "name": "candy" } },
                    { "text": { "description": "candy" } } 
                ]
            }
        },
        "filter": { 
            "and": [
                {
                    "terms" : {
                        "_parent": [ "4e7089a9b97d640b30695b7a", "4e7089eeb97d640b30695b7b" ]
                    }
                },
                { "range": { "start": { "lte": "2011-09-22" } } },
                { "range": { "end": { "gte": "2011-09-22" } } }
            ]
        }
    }
    

    You should query using the _parent field and passing it an array of IDs of locations to which you want to limit the exhibits.

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

Sidebar

Related Questions

This may seem a very silly question. Consider this: I have a simple Boolean
Very simple question about jstl. Consider Map which return by Controller/Servlet. I would like
Here's my hypothetical example. I have a very simple WPF window with a one
maybe a very simple question, however I have no idea what I do wrong,
I have a very simple WPF user control that is mixed in with a
I would like your suggestion about this problem... To make it simple, I'll consider
Consider the following two statements out of a very simple assembly language program: DATA1
I have a simple photo taking application that has the following design: [Consider the
I have made a very simple game in titanium mobile. I only use 90k
My question is very simple, I would like to know if the method CGImageSourceCreateWithData

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.