solrj json.facet не дает побочный результат в ответ - PullRequest
0 голосов
/ 05 июля 2019

Я пытаюсь получить грань от solrj мой код, как показано ниже. Я могу получить данные, выполнив sol-rquery в браузере

Я пытаюсь получить все поля одним вызовом в Java

        List<SimpleOrderedMap<Object>>buckets = (List<SimpleOrderedMap<Object>>) namedList.findRecursive(FACETS, "category",
                BUCKETS);



http://mysolrserver/solr/art-002/select?q=*:*&json.facet={categories : {type : terms,field: ap,limit : 3}, cat2 : {type : terms,field: ti,limit : 3}}



 final String FACETS = "facets";
 final String BUCKETS = "buckets";
 List<FacetData> facetDataList = new ArrayList<>();

SolrQuery solrQuery = new 

SolrQuery (fql2lucenePipe.getLuceneQueryMap () получим (WcCollectionType.ART.toString ()).);

        SolrClient solrClient = solrTemplateFactory.getSolrTemplate().getSolrClient();

        JsonFacet jsonFacet = new JsonFacet();
        JsonFacetField jsonFacetField = new JsonFacetField();
        jsonFacetField.setField("ti");
        jsonFacetField.setLimit(4);
        jsonFacetField.setType("terms");

        jsonFacet.setJsonFacetField(jsonFacetField);
        jsonFacet.setFacetLable("ap");
        System.out.println(JsonUtils.toJson(jsonFacetField));
        solrQuery.add("json.facet", "{category:" + JsonUtils.toJson(jsonFacetField) + "}");

        QueryResponse queryResponse =
                solrTemplateFactory.getSolrTemplate().getSolrClient().query("wc_art",
                        solrQuery);
        queryResponse.getRe
        NamedList namedList  = queryResponse.getResponse();
        List<SimpleOrderedMap<Object>>buckets = (List<SimpleOrderedMap<Object>>) namedList.findRecursive(FACETS, "category",
                BUCKETS);
        if (buckets != null) {
            for (SimpleOrderedMap<Object> bucket : buckets) {
               // String manufacturerLevel = (String) bucket.get(BUCKET_VAL);
                // manufacturer's name and total of all prices for this manufacturer
               // // Notice "manu_level_price" that was specified in json.facet
                System.out.println( bucket);
            }
            // Total prices of all manufacturers
            // notice "total_price" that was specified in json.facet and "findRecursive" usage
        }

I can fetch facet only for one field at a time.
is there a way to fetch all facet fields in one call?


...