Facets on Child Document

ES Version: 0.90.7

I want to search on parent type and facets on child type, there is an
example use case from
http://elasticsearch-users.115913.n3.nabble.com/Facets-on-child-documents-td
4037793.html

I followed the example:




Parent Docs
curl -XPUT 'http://esvm1:9200/pc/respondent/1' -d '{"rid": 1, "date":
"2011-11-18"}'
curl -XPUT 'http://esvm1:9200/pc/respondent/2' -d '{"rid": 2, "date":
"2011-11-19"}'
curl -XPUT 'http://esvm1:9200/pc/respondent/3' -d '{"rid": 3, "date":
"2011-11-17"}'
curl -XPUT 'http://esvm1:9200/pc/respondent/4' -d '{"rid": 4, "date":
"2011-11-18"}'
curl -XPUT 'http://esvm1:9200/pc/respondent/5' -d '{"rid": 5, "date":
"2011-11-18"}'
curl -XPUT 'http://esvm1:9200/pc/respondent/6' -d '{"rid": 6, "date":
"2011-11-19"}'

Insert some maps (Child docs) that happened to those respondents:

curl -XPOST 'http://esvm1:9200/pc/map/1_100?parent=1' -d '{"mapid": 100,
"value": 1}'
curl -XPOST 'http://esvm1:9200/pc/map/1_102?parent=1' -d '{"mapid": 102,
"text": "hi"}'
curl -XPOST 'http://esvm1:9200/pc/map/2_100?parent=2' -d '{"mapid": 100,
"value": 2}'
curl -XPOST 'http://esvm1:9200/pc/map/2_101?parent=2' -d '{"mapid": 101,
"value": 1}'
curl -XPOST 'http://esvm1:9200/pc/map/3_101?parent=3' -d '{"mapid": 101,
"value": 1}'
curl -XPOST 'http://esvm1:9200/pc/map/3_102?parent=3' -d '{"mapid": 102,
"text": "hello"}'
curl -XPOST 'http://esvm1:9200/pc/map/4_100?parent=4' -d '{"mapid": 100,
"value": 1}'
curl -XPOST 'http://esvm1:9200/pc/map/5_100?parent=5' -d '{"mapid": 100,
"value": 2}'
curl -XPOST 'http://esvm1:9200/pc/map/6_100?parent=6' -d '{"mapid": 100,
"value": 1}'

POST http://esvm1:9200/pc/respondent/_search
{
"query" : {
"has_child" : {
"type" : "map",
"query" : {
"match" : {
"mapid" : "101"
}
}
}
},
"facets" : {
"term1" : {
"terms" : {
"field" : "value"
},
"global" : true,
"facet_filter" : {
"term" : {
"mapid" : "100"
}
}
}
}
}




In the post
http://elasticsearch-users.115913.n3.nabble.com/Facets-on-child-documents-td
4037793.html , it said that we can get response:

terms: [
{ term: 1, count: 3},
{ term: 2, count: 2}
]

But in my experiment, no facets were returned,

"facets": {
"term1": {
"_type": "terms",
"missing": 0,
"total": 0,
"other": 0,
"terms": []
}
}

I find the same use case related to this purpose:
https://github.com/elasticsearch/elasticsearch/issues/2606 , but it seems
not work in 0.90.7 too.

Any idea? Thanks!

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/006e01cef558%240c6584f0%2425308ed0%24%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

If you don't the respondent type in the path of the url, then the global.
facet does return entries.
The type in the url path is used as filter for the query and also the
global facet.

On 10 December 2013 04:29, Guozhu Wei weiguozhu@gmail.com wrote:

ES Version: 0.90.7

I want to search on parent type and facets on child type, there is an
example use case from

http://elasticsearch-users.115913.n3.nabble.com/Facets-on-child-documents-td
4037793.html

I followed the example:




Parent Docs
curl -XPUT 'http://esvm1:9200/pc/respondent/1' -d '{"rid": 1, "date":
"2011-11-18"}'
curl -XPUT 'http://esvm1:9200/pc/respondent/2' -d '{"rid": 2, "date":
"2011-11-19"}'
curl -XPUT 'http://esvm1:9200/pc/respondent/3' -d '{"rid": 3, "date":
"2011-11-17"}'
curl -XPUT 'http://esvm1:9200/pc/respondent/4' -d '{"rid": 4, "date":
"2011-11-18"}'
curl -XPUT 'http://esvm1:9200/pc/respondent/5' -d '{"rid": 5, "date":
"2011-11-18"}'
curl -XPUT 'http://esvm1:9200/pc/respondent/6' -d '{"rid": 6, "date":
"2011-11-19"}'

Insert some maps (Child docs) that happened to those respondents:

curl -XPOST 'http://esvm1:9200/pc/map/1_100?parent=1' -d '{"mapid": 100,
"value": 1}'
curl -XPOST 'http://esvm1:9200/pc/map/1_102?parent=1' -d '{"mapid": 102,
"text": "hi"}'
curl -XPOST 'http://esvm1:9200/pc/map/2_100?parent=2' -d '{"mapid": 100,
"value": 2}'
curl -XPOST 'http://esvm1:9200/pc/map/2_101?parent=2' -d '{"mapid": 101,
"value": 1}'
curl -XPOST 'http://esvm1:9200/pc/map/3_101?parent=3' -d '{"mapid": 101,
"value": 1}'
curl -XPOST 'http://esvm1:9200/pc/map/3_102?parent=3' -d '{"mapid": 102,
"text": "hello"}'
curl -XPOST 'http://esvm1:9200/pc/map/4_100?parent=4' -d '{"mapid": 100,
"value": 1}'
curl -XPOST 'http://esvm1:9200/pc/map/5_100?parent=5' -d '{"mapid": 100,
"value": 2}'
curl -XPOST 'http://esvm1:9200/pc/map/6_100?parent=6' -d '{"mapid": 100,
"value": 1}'

POST http://esvm1:9200/pc/respondent/_search
{
"query" : {
"has_child" : {
"type" : "map",
"query" : {
"match" : {
"mapid" : "101"
}
}
}
},
"facets" : {
"term1" : {
"terms" : {
"field" : "value"
},
"global" : true,
"facet_filter" : {
"term" : {
"mapid" : "100"
}
}
}
}
}




In the post

http://elasticsearch-users.115913.n3.nabble.com/Facets-on-child-documents-td
4037793.html , it said that we can get response:

terms: [
{ term: 1, count: 3},
{ term: 2, count: 2}
]

But in my experiment, no facets were returned,

"facets": {
"term1": {
"_type": "terms",
"missing": 0,
"total": 0,
"other": 0,
"terms":
}
}

I find the same use case related to this purpose:
Remove scope support in query and facet dsl. · Issue #2606 · elastic/elasticsearch · GitHub , but it seems
not work in 0.90.7 too.

Any idea? Thanks!

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/006e01cef558%240c6584f0%2425308ed0%24%40gmail.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
Met vriendelijke groet,

Martijn van Groningen

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CA%2BA76TxUj0ZHLXNnSBpGoPvPbvZsh7UL3LGYepckAwWNdASZmQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.