Search code examples
solrsearch-engine

Lucene/Solr - how to return both relevant documents and authors based on query presence in documents?


We have successfully implemented Apache Solr to return the x most relevant dialogs as search results in our dialoging system.

Every dialog (node.nid) consists of comments (comment.cid), and each dialog/comment is authored by a user (node.uid / comment.uid).

Currently, Solr is configured to search through all dialog content (comments, users, timestamps etc). We would like to expand our search results to not only display dialogs most relevant to a query, but also return the most relevant authors.

The problem is that in order to determine the relevance of authors with respect to a query, we need Solr to distinguish between nodes and comments, and node.uid's and comment.uid's respectively.

Is it at all possible to return different types of search results using Solr: dialogs and authors, e.g. first displaying the top 5 authors with respect to a search query and then the top 50 relevant queries with respect to that same query.


Solution

  • Yes, it is possible to return different types of search results using Solr. Solr has an open schema, meaning that you can index whatever you want in Solr, as long as each document has a unique id. Thus, you can index authors and dialogs in the same Solr index. They should probably have different fields (e.g. author name and their dialog texts for author, just the dialog text for a dialog).

    I believe the DisMax query mode might help you, in scoring authors and dialogs differently.