简体   繁体   中英

Solr 4.8 faceting on nested documents

faceting on nested documents in solr 5.3 is possible with "JSON Facet API" http://yonik.com/solr-nested-objects/

I use Solr version 4.8 therefore I cannot use "JSON Facet API".

I have parent and children docs by using "Block Join Query": https://cwiki.apache.org/confluence/display/solr/Other+Parsers#OtherParsers-BlockJoinQueryParsers

As you can see in the document, I need to use ' Block Join Children Query Parser ' to get children docs: q={!child of="content_type:parentDocument"}title:lucene

and use " Block Join Parent Query Parser " to get parent docs: q={!parent which="content_type:parentDocument"}comments:SolrCloud

I want to use "Block Join Parent Query Parser" and have children fields as facet filter.

In other words, user use search phrase to search parent documents and use children fields as facet filters to filter docs.

Is there any way to do this?

as per the doc https://cwiki.apache.org/confluence/display/solr/JSON+Request+API

the json api looks like a way to present the arguments in the guise of a json object rather than a list of dotted.variable.names assignements:

(quoted from linked page above)

Facet Example

In fact, you don't even need to start with a JSON body for smart merging to be very useful. Consider the following request composed entirely of request params: curl http://localhost:8983/solr/techproducts/query -d 'q=*:*&rows=1& json.facet.avg_price="avg(price)"& json.facet.top_cats.terms={field:"cat",limit:5}'

That is equivalent to having the following JSON body or json parameter:

{
  facet: {
    avg_price: "avg(price)",
    top_cats: {
      terms: {
        field: "cat",
        limit:5
      }
    }
  }
}

(Edit: fixed markup for code)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM