cancel
Showing results for 
Search instead for 
Did you mean: 

Opening Alfresco document from Solr4 Search result

lvramanan
Champ in-the-making
Champ in-the-making

I'm using Alfresco 5.1 community Edition with Solr4 configured as Search Service and Transaction queries configured as Hybrid (Solr & DB)

When I do a search in Solr GUI from the below URL

Solr Query GUI: https://localhost:8443/solr4/#/alfresco/query

I get the search results in the below format with some ID & other info.

Solr Search Result (Results JSON truncated for readability)

{ "responseHeader": { "status": 0, "QTime": 25, "params": { "q": "testing", "defType": "dismax", "qt": "", "indent": "true", "wt": "json", "_": "1476349027637" } }, ... "docs": [ { "id": "_DEFAULT_!8000000000000040!80000000000008e3", "_version_": 0, "DBID": 2275 }, { "id": "_DEFAULT_!8000000000000072!8000000000000902", "_version_": 0, "DBID": 2306 }, { "id": "_DEFAULT_!8000000000000040!80000000000008ea", "_version_": 0, "DBID": 2282 }, { "id": "_DEFAULT_!800000000000000b!80000000000008ef", "_version_": 0, "DBID": 2287 }, { "id": "_DEFAULT_!8000000000000071!80000000000008f0", "_version_": 0, "DBID": 2288 }, { "id": "_DEFAULT_!8000000000000025!80000000000008eb", "_version_": 0, "DBID": 2283 } ] }, "processedDenies": false } 

I'm trying to build a UI where in these search results displayed, a user can click through to retrieve the respective document in Alfresco. Below is the Alfresco API I use to retrieve content from Alfresco.

Alfresco API URL to open a Document : http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom/content?id=

A sample Alfresco document ID looks like the one shown below. I don't get such ID returned in Solr4 search results.

Sample Document Id:

7edf97f4-43cf-4fe5-8099-85608776d159

Questions:

1) What is the ID returned by Solr4 ?
2) How do I get the relevant Alfresco document ID to be able to retrieve the same from the search result ?

Thanks in advance.

3 REPLIES 3

afaust
Legendary Innovator
Legendary Innovator

The "DBID" returned by SOLR is the raw database ID. The "id" is just an internally generated document ID and not associated with any data of the node. What you might want is the "ID" field which should be the NodeRef - the last uid fragment of the NodeRef (along with a version identifier) is what you'd need to use the CMIS API. Alternatively, you can also select the actual property fields for store protocol, identifier and the node uuid, but the names for these are very clunky.

zhihailiu
Champ on-the-rise
Champ on-the-rise

NodeService has a method to get NodeRef from DBID. That's what Alfresco does in SolrJSONResultSet.java.

NodeRef nodeRef = nodeService.getNodeRef(dbid);

You can do similar "post-processing" of the data returned from Solr.