Including Collection Names in Query Results
Scenario
The default query result of Solr does not include a collection name. When querying multiple collections, users cannot distinguish the specific collection to which the data belongs because query results mix with each other. In this case, collection names need to be included in the query results.
Prerequisites
The Solr service has been installed.
Procedure
- For Solr Admin UI,
In Raw Query Parameters, enter echoCollection=true&collection=collection_1,collection_2. collection_1 and collection_2 are the names of the collections to be searched for. The returned result contains the _collection_ field. The following is an example:
- For Java APIs,
The example code is as follows:
SolrQuery solrQuery = new SolrQuery() .setStart(start).setRows(rows) .setFields(returnFileds) .setQuery(mainQuery) .setFilterQueries(filterQuery); solrQuery.set("collection", collection); solrQuery.setParam("echoCollection",true);
- If distrib=false is enabled when querying, the collection name is not included in the query result.
- When only one collection is searched, the returned result cannot contain the collection name.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot