Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Solr query question

Solved Go to solution

Solr query question

New Contributor

Hi,

Let's say I only have 2 fields in a document: "animal" and "born_date"

A few examples of document:

{animal:"cat", born_date:"1/1/2015" },{animal:"dog", born_date:"1/1/2015" },{animal:"snake", born_date:"1/3/2015" },...........

Is it possible to write a facet query to generate the following result?

{ 

"cat": [

	"1/1/2015", 123,

	"1/2/2015",423,

	"1/3/2015",32,

	....

	"12/31/2015",32],

"dog": [

	"1/1/2015", 23,

	"1/2/2015",43,

	"1/3/2015",88,

	....

	"12/31/2015",4],

"snake": [

	"1/1/2015", 23,

	"1/2/2015",67,

	"1/3/2015",2,

	....

	"12/31/2015",6]

}

-Wing

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Solr query question

Expert Contributor

What do you want to do with the results?

Are you going to summarize the results?

  1. You may want to look at pivoting a facet for summarizing the result.
  2. If you just want to group them. Don't forget to set a limit so a reasonable result is returned.

let me know if this is what you where looking for.

5 REPLIES 5

Re: Solr query question

Expert Contributor

What do you want to do with the results?

Are you going to summarize the results?

  1. You may want to look at pivoting a facet for summarizing the result.
  2. If you just want to group them. Don't forget to set a limit so a reasonable result is returned.

let me know if this is what you where looking for.

Re: Solr query question

New Contributor

Thanks for the suggestions and I'll look them up. Basically I want to visualize the data on a line chart. Each line represent one type of animal and I don't know how many types of animal in the solr collection.

Can I use facet range with group? then I can show the count on each day within the group?

Re: Solr query question

Expert Contributor

From what you have told me sounds like you should use a facet pivot and specifically checkout "Combining Facet Queries And Facet Ranges With Pivot Facets" it has an example that fits right into what you want to do.

Re: Solr query question

New Contributor

The facet pivot is exactly what I need! Thank you so much, Matt!

Re: Solr query question

Hi @Wing Lo If facet pivot is exactly what you need how about accepting and upvoting Matt's answer? Thanks!

Don't have an account?
Coming from Hortonworks? Activate your account here