From dc1c512367d5d4170f54bf36c957371e05e00dc7 Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Mon, 15 Dec 2025 17:13:14 -0500 Subject: [PATCH 1/2] fixing small issues in the MLT examples. --- .../query-guide/pages/morelikethis.adoc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/solr/solr-ref-guide/modules/query-guide/pages/morelikethis.adoc b/solr/solr-ref-guide/modules/query-guide/pages/morelikethis.adoc index e329ca0977e..c495b096eae 100644 --- a/solr/solr-ref-guide/modules/query-guide/pages/morelikethis.adoc +++ b/solr/solr-ref-guide/modules/query-guide/pages/morelikethis.adoc @@ -47,6 +47,11 @@ The field used for the `uniqueKey` must also be stored in order for MoreLikeThis Terms from the original document are filtered using thresholds defined with the MoreLikeThis parameters. Once the terms have been selected, a query is run with any other query parameters as appropriate and a new document set is returned. +The examples listed assume that you have loaded the example book data into Solr via: + +[source,bash] +bin/solr post -c gettingstarted example/exampledocs/books.csv + == MoreLikeThis Handler and Component The MoreLikeThis request handler and search component share several parameters, but also have some key differences in response and operation, as described below. @@ -196,7 +201,7 @@ Manual Configuration:: [source,xml] ---- - body + text ---- ==== @@ -206,19 +211,19 @@ Config API:: ==== [source,bash] ---- -curl -X POST -H 'Content-type:application/json' -d { +curl -X POST -H 'Content-type:application/json' -d '{ "add-requesthandler": { "name": "/mlt", "class": "solr.MoreLikeThisHandler", - "defaults": {"mlt.fl": "body"} + "defaults": {"mlt.fl": "text"} } -} http://localhost:8983/solr//config +}' http://localhost:8983/solr/gettingstarted/config ---- ==== ====== -Both of the above examples set the `mlt.fl` parameter to "body" for the request handler. -This means that all requests to the handler will use that value for the parameter unless specifically overridden in an individual request. +Both of the above examples set the `mlt.fl` parameter to "text" for the request handler. +This means that all requests to the handler will use that field for the parameter unless specifically overridden in an individual request. For more about request handler configuration in general, see the section xref:configuration-guide:requesthandlers-searchcomponents.adoc#default-components[Default Components]. @@ -647,4 +652,3 @@ The query parser response includes only the similar documents sorted by score: === Query Parser for External Content Use `{!mlt_content}lorem ipsum` or `{!mlt_content q='lorem ipsum'}` to find docs similar to an external content absent in index in SolrCloud mode like `/mlt` handler and content streams. Parameters and response are the same as above. It queries fields passed via `qf` parameter with the given content. When `qf` is omitted it queries all fields in the schema that usually fails on numerics and other specific formatted field types. If you need to query different fields with different content combine several `{!mlt_content qf=fieldA}lorem ipsum` with `{!bool}` query or other. - From 49ba4e048ec1ff56a7451652dbed0ca99c5bdaeb Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Mon, 15 Dec 2025 17:16:54 -0500 Subject: [PATCH 2/2] Rewording the last paragraph, still want an example. --- .../modules/query-guide/pages/morelikethis.adoc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/solr/solr-ref-guide/modules/query-guide/pages/morelikethis.adoc b/solr/solr-ref-guide/modules/query-guide/pages/morelikethis.adoc index c495b096eae..6d0e83ce0f1 100644 --- a/solr/solr-ref-guide/modules/query-guide/pages/morelikethis.adoc +++ b/solr/solr-ref-guide/modules/query-guide/pages/morelikethis.adoc @@ -651,4 +651,13 @@ The query parser response includes only the similar documents sorted by score: === Query Parser for External Content -Use `{!mlt_content}lorem ipsum` or `{!mlt_content q='lorem ipsum'}` to find docs similar to an external content absent in index in SolrCloud mode like `/mlt` handler and content streams. Parameters and response are the same as above. It queries fields passed via `qf` parameter with the given content. When `qf` is omitted it queries all fields in the schema that usually fails on numerics and other specific formatted field types. If you need to query different fields with different content combine several `{!mlt_content qf=fieldA}lorem ipsum` with `{!bool}` query or other. +The `mlt_content` query parser enables finding documents similar to external content that is not present in the index. +This provides functionality similar to the <>, but works in SolrCloud mode. + +Use the syntax `{!mlt_content}lorem ipsum` or `{!mlt_content q='lorem ipsum'}` to provide the content for similarity matching. +The query parser supports the same parameters as the <>. + +By default, the parser queries the fields specified in the `qf` parameter with the given content. +When `qf` is omitted, it queries all fields in the schema, which typically fails on numeric and other specifically formatted field types. + +To query different fields with different content, combine multiple `{!mlt_content qf=fieldA}lorem ipsum` queries using the `{!bool}` query parser or other suitable query parsers.