Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Solr query question

avatar
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

avatar
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.

View solution in original post

5 REPLIES 5

avatar
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.

avatar
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?

avatar
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.

avatar
Contributor

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

avatar
Master Guru

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