Sashi
Sashi

Reputation: 2425

How do I apply Solr 'More Like This' component as part of my search

I'm trying to perform a solr query that includes 'More Like This' component. Can't find this scenario in the documentation. Here's a hypothetical sample Product entity with two fields -

{
   product_name: "name of the product in 3 or 4 words"
   product_description: "this is a long english verbose text, may be 10 
   sentences"    
}

If I'm given a newProduct, I want to search for similar products in my Solr Index. The search should use the following logic -

How can this be accomplished with a single query to Solr?

Let me know if the scenario is not clear.

Upvotes: 1

Views: 1208

Answers (2)

Arjun Ramesh
Arjun Ramesh

Reputation: 189

I think this is what you are looking for: https://wiki.apache.org/solr/MoreLikeThis#MoreLikeThisComponent

It uses the MoreLikeThis Component in search rather than having a separate handler.

Upvotes: 0

MatsLindh
MatsLindh

Reputation: 52892

You can use the More Like This request handler (mlt) to perform a "More Like Search" with a given document text without adding the document to the index first.

Include the document as the POST data or in the stream.body parameter in the request. There's an example given in the old wiki - see "Using content streams":

If you post text in the body, that will be used for similarity. Alternatively, you can put the posted content in the URL using something like:

http://localhost:8983/solr/mlt?stream.body=electronics%20memory&mlt.fl=manu,cat&mlt.interestingTerms=list&mlt.mintf=0

If remoteStreaming is enabled, you can find documents similar to the text on a webpage:

http://localhost:8983/solr/mlt?stream.url=http://lucene.apache.org/solr/&mlt.fl=manu,cat&mlt.interestingTerms=list&mlt.mintf=0

Upvotes: 1

Related Questions