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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:36:57+00:00 2026-06-05T08:36:57+00:00

I have the response in the following format after doing groupby in solr query.

  • 0

I have the response in the following format after doing groupby in solr query. I am using solr version 3.5

"grouped":{
    "channel_id":{
      "matches":48,
      "ngroups":26,
      "groups":[{
          "groupValue":"204",
          "doclist":{"numFound":1,"start":0,"docs":[
              {
                "channel_name":"ZeeTv",
                "channel_num":4,
                "title":"The Name",
                "channel_id":"204"
          }},
        {
          "groupValue":"166",
          "doclist":{"numFound":2,"start":0,"docs":[
              {
                "channel_name":"Sony",
                "channel_num":2,
                "title":"The Name",
                "channel_id":"166",
              {
                "channel_name":"Sony",
                "channel_num":2,
                "title":"The Puzzle",
                "channel_id":"166"
          }}]}}

I am taking the response in an array in the following way :

for(var chl in data.grouped.channel_id.groups) {
    config['playlist'].push(data.grouped.channel_id.groups[chl]['doclist']['docs']); 
}

Thus an individual array of each groupValue is formed. The struture of the array is:

"0"=>{"0"=>"value"},"1"=>{"0"=>"result1","1"=>"result2"}

But i want to change the key name i.e. “0”,”1″ to the groupValue from the response while creating an array so that i can do config['playlist']['166'] to check all the shows for this channel_id from the array. Can this be done and if so how. I am expecting the following :

"204"=>{"0"=>"value"},"166"=>{"0"=>"result1","1"=>"result2"}

Also if possible can the solr query be made such that the channel_num in the response comes in ascending order i.e. first result for channel_num 2 and then 4. I have done groupby:channel_id

  • 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-05T08:36:59+00:00Added an answer on June 5, 2026 at 8:36 am

    What about that?

    for(var chl in data.grouped.channel_id.groups) {
        config['playlist'][data.grouped.channel_id.groups[chl].groupValue] = data.grouped.channel_id.groups[chl]['doclist']['docs'];
    }
    

    Push is there to add an element at the end of an array. But any Javascript object is just a hash table, so you can use it that way.

    By the way, you can make the code simpler with a for each :

    for each(var chl in data.grouped.channel_id.groups) {
        config['playlist'][ch1.groupValue] = ch1['doclist']['docs'];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following LINQ expression that's not returning the appropriate response var query
I have an xml document with the following format: <response username=123 customerName=CustomerName siteName=SiteName customerID=123
I have the following response in JSON format, but, can't seem to figure out
I have the following code Response.TransmitFile(filePath); Opens the new window using the following line
I have the following array response from a server to an android app. [
In my servlet I have the following code: response.setContentType(application/json);//set json content type PrintWriter out
I have following xml as a response to a service not i want to
I have the following JSON object: { response: { status: 200 }, messages: [
I have the following code to add authentication cookie to the response and redirect
I have the following block of code in my bean class - HttpServletResponse response

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.