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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:18:07+00:00 2026-06-10T21:18:07+00:00

I have a facet count problem while using arrays. I have a gist which

  • 0

I have a facet count problem while using arrays. I have a gist which you guys can have look at in order to see my actual mapping and the documents I’m indexing: https://gist.github.com/3607876 .

Briefly, I’m submitting this query throught the search API:

curl -XPOST 'localhost:9200/org/_search?pretty=true' -d '
{
    "query" : {
        "term" : { "participating-org.role" : "leading" }
    },
    "filter" : {
        "term" : { "participating-org.role" : "leading" }
    },
    "facets" : {
        "organization_facets" : {
            "terms" : { "field" : "participating-org.name" }
        }
    }
}'

and I’m getting back the following facet:

facets: {
    participating-org.name: {
        _type: "terms"
        missing: 0
        total: 8
        other: 0
        terms: [
            {
                term: "def"
                count: 4
            }
            {
                term: "abc"
                count: 4
            }
        ]
    }
}

I wouldn’t expect the “def” entry here since its participating-org object has always “leading” role and I’m trying to filter those entries out. I don’t know why there is count for “abc” participating-org too which is not in “leading” role.

Do you guys have any suggestions? Is it my mappings or the facets query problems?

  • 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-06-10T21:18:09+00:00Added an answer on June 10, 2026 at 9:18 pm

    You can remove the filter

    "filter" : {
        "term" : { "participating-org.role" : "leading" }
    }
    

    since it doesn’t make any difference. Filters are not taken into account while computing the facet counts, they are only taken into account to filter the search results.

    The query

    "query" : {
        "term" : { "participating-org.role" : "leading" }
    }
    

    does make a difference for both your documents and your facet, but in fact you are asking elasticsearch to give you all the documents with participating-org.role leading, and compute the facets out of those search results. The filter that you’re trying to apply is applied to the returned documents, and the returned documents are used to make the facet. Your documents have multiple participating-org inner objects, and of them has always role leading, that’s why you’re selecting all documents with that query. Yo’re filtering the top level documents
    If you only want to exclude a specific facet entry you can do it, but I think you’d be more interested in the nested documents support. You can have a look at the Nested type, this great article about it and how to make facets baed on nested documents at the bottom of this page.

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

Sidebar

Related Questions

I have a problem with using facet. I need autocomplete and for this I
I'm trying to use XPath to select the items which have a facet with
I'm plotting a group of curves, using facet in ggplot2. I'd like to have
I have a big problem when using Ryan Bates' excellent Nested_form gem. In fact,
I've been using Rapidxml lately and have faced following problem. When I try to
The problem is strange, I have a combobox which is correctly filled with items
I have a measure, that's a distinct count on a field in the fact
I have faced a problem in Qt with error: cannot convert parameter 1 from
I have faced the same problem many times. The Same Problem was With This
I have a problem that I have not faced before: It seems that the

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.