From e5843b4e718c279d57157ec870ad2f95417f98a7 Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Mon, 23 Nov 2009 05:07:39 +0000 Subject: [PATCH] add some additional non-text fields to MTL handler test git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@883246 13f79535-47bb-0310-9956-ffa450edef68 --- .../solr/handler/MoreLikeThisHandlerTest.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/test/org/apache/solr/handler/MoreLikeThisHandlerTest.java b/src/test/org/apache/solr/handler/MoreLikeThisHandlerTest.java index adcf190a0dc..c943a2c3102 100644 --- a/src/test/org/apache/solr/handler/MoreLikeThisHandlerTest.java +++ b/src/test/org/apache/solr/handler/MoreLikeThisHandlerTest.java @@ -48,7 +48,7 @@ public class MoreLikeThisHandlerTest extends AbstractSolrTestCase { } - public void testInterface() + public void testInterface() throws Exception { SolrCore core = h.getCore(); MoreLikeThisHandler mlt = new MoreLikeThisHandler(); @@ -73,20 +73,21 @@ public class MoreLikeThisHandlerTest extends AbstractSolrTestCase { } catch( Exception ex ) {} // expected - assertU(adoc(new String[]{"id","42","name","Tom Cruise","subword","Top Gun","subword","Risky Business","subword","The Color of Money","subword","Minority Report","subword", "Days of Thunder","subword", "Eyes Wide Shut","subword", "Far and Away"})); - assertU(adoc(new String[]{"id","43","name","Tom Hanks","subword","The Green Mile","subword","Forest Gump","subword","Philadelphia Story","subword","Big","subword","Cast Away"})); - assertU(adoc(new String[]{"id","44","name","Harrison Ford","subword","Star Wars","subword","Indiana Jones","subword","Patriot Games","subword","Regarding Henry"})); - assertU(adoc(new String[]{"id","45","name","George Harrison","subword","Yellow Submarine","subword","Help","subword","Magical Mystery Tour","subword","Sgt. Peppers Lonley Hearts Club Band"})); - assertU(adoc(new String[]{"id","46","name","Nicole Kidman","subword","Batman","subword","Days of Thunder","subword","Eyes Wide Shut","subword","Far and Away"})); + assertU(adoc("id","42","name","Tom Cruise","subword","Top Gun","subword","Risky Business","subword","The Color of Money","subword","Minority Report","subword", "Days of Thunder","subword", "Eyes Wide Shut","subword", "Far and Away", "foo_ti","10")); + assertU(adoc("id","43","name","Tom Hanks","subword","The Green Mile","subword","Forest Gump","subword","Philadelphia Story","subword","Big","subword","Cast Away", "foo_ti","10")); + assertU(adoc("id","44","name","Harrison Ford","subword","Star Wars","subword","Indiana Jones","subword","Patriot Games","subword","Regarding Henry")); + assertU(adoc("id","45","name","George Harrison","subword","Yellow Submarine","subword","Help","subword","Magical Mystery Tour","subword","Sgt. Peppers Lonley Hearts Club Band")); + assertU(adoc("id","46","name","Nicole Kidman","subword","Batman","subword","Days of Thunder","subword","Eyes Wide Shut","subword","Far and Away")); assertU(commit()); params.put(CommonParams.Q, new String[]{"id:42"}); params.put(MoreLikeThisParams.MLT, new String[]{"true"}); - params.put(MoreLikeThisParams.SIMILARITY_FIELDS, new String[]{"name,subword"}); + params.put(MoreLikeThisParams.SIMILARITY_FIELDS, new String[]{"name,subword,foo_ti"}); params.put(MoreLikeThisParams.INTERESTING_TERMS,new String[]{"details"}); params.put(MoreLikeThisParams.MIN_TERM_FREQ,new String[]{"1"}); params.put(MoreLikeThisParams.MIN_DOC_FREQ,new String[]{"1"}); - + params.put("indent",new String[]{"true"}); + SolrQueryRequest mltreq = new LocalSolrQueryRequest( core, (SolrParams)mmparams); assertQ("morelikethis - tom cruise",mltreq ,"//result/doc[1]/int[@name='id'][.='46']" @@ -101,6 +102,10 @@ public class MoreLikeThisHandlerTest extends AbstractSolrTestCase { assertQ("morelikethis with weights",mltreq ,"//result/doc[1]/int[@name='id'][.='43']" ,"//result/doc[2]/int[@name='id'][.='46']"); - + + // params.put(MoreLikeThisParams.QF,new String[]{"foo_ti"}); + // String response = h.query(mltreq); + // System.out.println(response); + } }