SolrDocumentList для JSON игнорирует свойство numFound в ответе solrj - PullRequest
0 голосов
/ 26 сентября 2018

ниже - мои данные solrDocumentList

{numFound=16,start=0,docs=[SolrDocument{cluster=Horton, source=MUSE}]}

Но при возврате в качестве Json свойство numFound и start игнорируется.

code

    // Preparing Solr query
    SolrQuery query = new SolrQuery();
    query.setQuery(searchString);

    // Adding the field to be retrieved

    query.addField("*");
    query.setStart(start);
    query.setRows(rows);


    // Executing the query
    QueryResponse queryResponse = Solr.query(query);
    // Storing the results of the query
    SolrDocumentList docs = queryResponse.getResults();

    System.out.println("queryResponse is :" + docs);

    Solr.close();


    return docs;

OutPutОтвет:

[{cluster=Horton, source=MUSE}]

Я ожидаю вывод, как показано ниже, (массив json)

[doc: {cluster=Horton, source=MUSE},
 numFound:0
]

Любая помощь приветствуется.

1 Ответ

0 голосов
/ 26 сентября 2018

Вы получите numFound с использованием следующего метода.

queryResponse.getResults (). GetNumFound ();

http://lucene.apache.org/solr/6_5_1/solr-solrj/index.html?org/apache/solr/client/solrj/response/QueryResponse.html

...