Solr MoreLikeThis: Can I give Solr 5 document IDs

2019-07-20 03:08发布

问题:

I'm unclear on this point from the documentation. Is it possible to give Solr X document IDs and tell it that I want documents similar to those?

Example:

  • The user is browsing 5 different articles
  • I send Solr the IDs of these 5 articles so I can present the user other similar articles

I am not clear about sending the document IDs, nor whether MoreLikeThis can operate on multiple documents as in this example.

回答1:

you can try passing multiple Ids with the Query q=id:(document_id1 OR document_id2 OR document_id3) :-

e.g.

http://localhost:8080/solr/select/?qt=mlt&q=id:(document_id1 OR document_id2 OR document_id3)&mlt.fl=[field1],[field2],[field3]&fl=id&rows=10