Using JSON Request API for MoreLikeThis results

53 views Asked by At

I can easily query my Solr index using the JSON Request API. Is it possible to find MoreLikeThis documents using the JSON Request API and the RequestHandler ?

Simple JSON query (as per documentation):

url:  http://localhost:8983/solr/techproducts/query
body: 
{
  "query" : "memory",
  "filter" : "inStock:true"
}

The MoreLikeThis query looks like this:

url: http://localhost:8983/solr/techproducts/mlt?mlt.fl=author&mlt.mindf=0&mlt.mintf=0&q=id%3A0553573403

Is it possible to translate the above into the body of a JSON request ?

Thanks for any help!

Note: I know I can include MLT documents in a query result using the SearchComponent RequestHandler, but that's not what I want.

1

There are 1 answers

0
jhfelectric On

Posting own answer here...

Using the MoreLikeThis Query Parser, it seems possible to retrieve MLT records.

This

url: http://localhost:8983/solr/techproducts/mlt?mlt.fl=author&mlt.mindf=0&mlt.mintf=0&q=id%3A0553573403

Would translate to this

url: http://localhost:8983/solr/techproducts/query
body: 
{
    "query": "{!mlt qf=author mintf=0 mindf=0}0553573403"
}

According to the doc (https://solr.apache.org/guide/solr/latest/query-guide/morelikethis.html#morelikethis-query-parser) the MLT Query Parser uses the document's unique key to identify documents.

Hope this helps !