You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by xavi jmlucjav <jm...@gmail.com> on 2015/11/19 12:50:15 UTC
Json Facet api on nested doc
Hi,
I am trying to get some faceting with the json facet api on nested doc, but
I am having issues. Solr 5.3.1.
This query gest the buckets numbers ok:
curl http://shost:8983/solr/collection1/query -d 'q=*:*&rows=0&
json.facet={
yearly-salaries : {
type: terms,
field: salary,
domain: { blockChildren : "parent:true" }
}
}
'
Salary is a field in child docs only. But if I add another facet outside
it, the inner one returns no data:
curl http://shost:8983/solr/collection1/query -d 'q=*:*&rows=0&
json.facet={
department:{
type: terms,
field: department,
facet:{
yearly-salaries : {
type: terms,
field: salary,
domain: { blockChildren : "parent:true" }
}
}
}
}
'
Results in:
"facets":{
"count":3144071,
"department":{
"buckets":[{
"val":"Development",
"count":85707,
"yearly-salaries":{
"buckets":[]}},
department is field only in parent docs. Am I doing something wrong that I
am missing?
thanks
xavi
Re: Json Facet api on nested doc
Posted by xavi jmlucjav <jm...@gmail.com>.
Mikahil, Yonik
thanks for having a look. This was my bad all the time...I forgot I was on
5.2.1 instead of 5.3.1 on this setup!! It seems some things were not there
yet on 5.2.1, I just upgraded to 5.3.1 and my query works perfectly.
Although I do agree with Mikhail the docs on this feature are a bit light,
it is understandable though, as it is quite new.
thanks
xavi
On Mon, Nov 23, 2015 at 9:24 PM, Mikhail Khludnev <
mkhludnev@griddynamics.com> wrote:
> Indeed! Now it works for me too. JSON Facets seems powerful, but not
> friendly to me.
> Yonik, thanks for example!
>
> Xavi,
>
> I took json docs from http://yonik.com/solr-nested-objects/ and just
> doubled book2_c3
>
> Here is what I have with json.facet={catz: {type:terms,field:cat_s,
> facet:{ starz:{type:terms, field:stars_i,
> domain:{blockChildren:'type_s:book'}} }}}
>
> {
> "responseHeader": {
> "status": 0,
> "QTime": 2,
> "params": {
> "q": "publisher_s:*",
> "json.facet": "{catz: {type:terms,field:cat_s, facet:{ starz:{type:terms, field:stars_i, domain:{blockChildren:'type_s:book'}} }}}",
> "indent": "true",
> "wt": "json",
> "_": "1448309900982"
> }
> },
> "response": {
> "numFound": 2,
> "start": 0,
> "docs": [
> {
> "id": "book1",
> "type_s": "book",
> "title_t": "The Way of Kings",
> "author_s": "Brandon Sanderson",
> "cat_s": "fantasy",
> "pubyear_i": 2010,
> "publisher_s": "Tor",
> "_version_": 1518570756086169600
> },
> {
> "id": "book2",
> "type_s": "book",
> "title_t": "Snow Crash",
> "author_s": "Neal Stephenson",
> "cat_s": "sci-fi",
> "pubyear_i": 1992,
> "publisher_s": "Bantam",
> "_version_": 1518570908026929200
> }
> ]
> },
> "facets": {
> "count": 2,
> "catz": {
> "buckets": [
> {
> "val": "fantasy",
> "count": 1,
> "starz": {
> "buckets": [
> {
> "val": 3,
> "count": 1
> },
> {
> "val": 5,
> "count": 1
> }
> ]
> }
> },
> {
> "val": "sci-fi",
> "count": 1,
> "starz": {
> "buckets": [
> {
> "val": 2,
> "count": 2
> },
> {
> "val": 4,
> "count": 1
> },
> {
> "val": 5,
> "count": 1
> }
> ]
> }
> }
> ]
> }
> }
> }
>
> It works well with *:* too.
>
>
> On Mon, Nov 23, 2015 at 12:56 AM, Yonik Seeley <ys...@gmail.com> wrote:
>
>> On Sun, Nov 22, 2015 at 3:10 PM, Mikhail Khludnev
>> <mk...@griddynamics.com> wrote:
>> > Hello,
>> >
>> > I also played with json.facet, but couldn't achieve the desired result
>> too.
>> >
>> > Yonik, Alessandro,
>> > Do you think it's a new feature or it can be achieved with the current
>> > implementation?
>>
>> Not sure if I'm misunderstanding the example, but it looks
>> straight-forward.
>>
>> terms facet on parent documents, with sub-facet on child documents.
>> I just committed a test for this, and it worked fine. See
>> TestJsonFacets.testBlockJoin()
>>
>> Can we see an example of a parent document being indexed (i.e. along
>> with it's child documents)?
>>
>> -Yonik
>>
>
>
>
> --
> Sincerely yours
> Mikhail Khludnev
> Principal Engineer,
> Grid Dynamics
>
> <http://www.griddynamics.com>
> <mk...@griddynamics.com>
>
Re: Json Facet api on nested doc
Posted by Mikhail Khludnev <mk...@griddynamics.com>.
Indeed! Now it works for me too. JSON Facets seems powerful, but not
friendly to me.
Yonik, thanks for example!
Xavi,
I took json docs from http://yonik.com/solr-nested-objects/ and just
doubled book2_c3
Here is what I have with json.facet={catz: {type:terms,field:cat_s, facet:{
starz:{type:terms, field:stars_i, domain:{blockChildren:'type_s:book'}} }}}
{
"responseHeader": {
"status": 0,
"QTime": 2,
"params": {
"q": "publisher_s:*",
"json.facet": "{catz: {type:terms,field:cat_s, facet:{
starz:{type:terms, field:stars_i,
domain:{blockChildren:'type_s:book'}} }}}",
"indent": "true",
"wt": "json",
"_": "1448309900982"
}
},
"response": {
"numFound": 2,
"start": 0,
"docs": [
{
"id": "book1",
"type_s": "book",
"title_t": "The Way of Kings",
"author_s": "Brandon Sanderson",
"cat_s": "fantasy",
"pubyear_i": 2010,
"publisher_s": "Tor",
"_version_": 1518570756086169600
},
{
"id": "book2",
"type_s": "book",
"title_t": "Snow Crash",
"author_s": "Neal Stephenson",
"cat_s": "sci-fi",
"pubyear_i": 1992,
"publisher_s": "Bantam",
"_version_": 1518570908026929200
}
]
},
"facets": {
"count": 2,
"catz": {
"buckets": [
{
"val": "fantasy",
"count": 1,
"starz": {
"buckets": [
{
"val": 3,
"count": 1
},
{
"val": 5,
"count": 1
}
]
}
},
{
"val": "sci-fi",
"count": 1,
"starz": {
"buckets": [
{
"val": 2,
"count": 2
},
{
"val": 4,
"count": 1
},
{
"val": 5,
"count": 1
}
]
}
}
]
}
}
}
It works well with *:* too.
On Mon, Nov 23, 2015 at 12:56 AM, Yonik Seeley <ys...@gmail.com> wrote:
> On Sun, Nov 22, 2015 at 3:10 PM, Mikhail Khludnev
> <mk...@griddynamics.com> wrote:
> > Hello,
> >
> > I also played with json.facet, but couldn't achieve the desired result
> too.
> >
> > Yonik, Alessandro,
> > Do you think it's a new feature or it can be achieved with the current
> > implementation?
>
> Not sure if I'm misunderstanding the example, but it looks
> straight-forward.
>
> terms facet on parent documents, with sub-facet on child documents.
> I just committed a test for this, and it worked fine. See
> TestJsonFacets.testBlockJoin()
>
> Can we see an example of a parent document being indexed (i.e. along
> with it's child documents)?
>
> -Yonik
>
--
Sincerely yours
Mikhail Khludnev
Principal Engineer,
Grid Dynamics
<http://www.griddynamics.com>
<mk...@griddynamics.com>
Re: Json Facet api on nested doc
Posted by Yonik Seeley <ys...@gmail.com>.
On Sun, Nov 22, 2015 at 3:10 PM, Mikhail Khludnev
<mk...@griddynamics.com> wrote:
> Hello,
>
> I also played with json.facet, but couldn't achieve the desired result too.
>
> Yonik, Alessandro,
> Do you think it's a new feature or it can be achieved with the current
> implementation?
Not sure if I'm misunderstanding the example, but it looks straight-forward.
terms facet on parent documents, with sub-facet on child documents.
I just committed a test for this, and it worked fine. See
TestJsonFacets.testBlockJoin()
Can we see an example of a parent document being indexed (i.e. along
with it's child documents)?
-Yonik
Re: Json Facet api on nested doc
Posted by Mikhail Khludnev <mk...@griddynamics.com>.
Hello,
I also played with json.facet, but couldn't achieve the desired result too.
Yonik, Alessandro,
Do you think it's a new feature or it can be achieved with the current
implementation?
On Thu, Nov 19, 2015 at 2:50 PM, xavi jmlucjav <jm...@gmail.com> wrote:
> Hi,
>
> I am trying to get some faceting with the json facet api on nested doc, but
> I am having issues. Solr 5.3.1.
>
> This query gest the buckets numbers ok:
>
> curl http://shost:8983/solr/collection1/query -d 'q=*:*&rows=0&
> json.facet={
> yearly-salaries : {
> type: terms,
> field: salary,
> domain: { blockChildren : "parent:true" }
> }
> }
> '
> Salary is a field in child docs only. But if I add another facet outside
> it, the inner one returns no data:
>
> curl http://shost:8983/solr/collection1/query -d 'q=*:*&rows=0&
> json.facet={
> department:{
> type: terms,
> field: department,
> facet:{
> yearly-salaries : {
> type: terms,
> field: salary,
> domain: { blockChildren : "parent:true" }
> }
> }
> }
> }
> '
> Results in:
>
> "facets":{
>
> "count":3144071,
>
> "department":{
>
> "buckets":[{
>
> "val":"Development",
>
> "count":85707,
>
> "yearly-salaries":{
>
> "buckets":[]}},
>
>
> department is field only in parent docs. Am I doing something wrong that I
> am missing?
> thanks
> xavi
>
--
Sincerely yours
Mikhail Khludnev
Principal Engineer,
Grid Dynamics
<http://www.griddynamics.com>
<mk...@griddynamics.com>