本文整理汇总了C#中SolrBasicServer.MoreLikeThis方法的典型用法代码示例。如果您正苦于以下问题:C# SolrBasicServer.MoreLikeThis方法的具体用法?C# SolrBasicServer.MoreLikeThis怎么用?C# SolrBasicServer.MoreLikeThis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SolrBasicServer
的用法示例。
在下文中一共展示了SolrBasicServer.MoreLikeThis方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoreLikeThisHandlerQuery
public void MoreLikeThisHandlerQuery()
{
const string qstring = "id:123";
var connection = new MSolrConnection();
connection.get += (url, param) => {
Assert.AreEqual("/mlt", url);
var expectedParams = new Dictionary<string, string> {
{"q", qstring},
{"rows", SolrQueryExecuter<TestDocumentWithUniqueKey>.ConstDefaultRows.ToString() },
{"mlt", "true"},
{"mlt.fl", "id"},
{"mlt.match.include", "true"},
};
Assert.AreElementsEqualIgnoringOrder(expectedParams, param);
return EmbeddedResource.GetEmbeddedString(GetType(), "Resources.responseWithInterestingTermsDetails.xml");
};
var querySerializer = new MSolrQuerySerializer();
querySerializer.serialize &= x => x.Return(qstring);
var mlthParser = new MSolrMoreLikeThisHandlerQueryResultsParser<TestDocumentWithUniqueKey>();
mlthParser.parse += _ => new SolrMoreLikeThisHandlerResults<TestDocumentWithUniqueKey>();
var executer = new SolrQueryExecuter<TestDocumentWithUniqueKey>(null, connection, querySerializer, null, mlthParser);
var solr = new SolrBasicServer<TestDocumentWithUniqueKey>(connection, executer, null, null, null, null, null, null);
var r = solr.MoreLikeThis(new SolrMoreLikeThisHandlerQuery(new SolrQuery(qstring)), new MoreLikeThisHandlerQueryOptions(new MoreLikeThisHandlerParameters(new[] { "id" }) { MatchInclude = true }));
Assert.AreEqual(1, connection.get.Calls);
}
示例2: MoreLikeThisHandlerQuery
public void MoreLikeThisHandlerQuery()
{
const string qstring = "id:123";
RhinoMocks.Logger = new Rhino.Mocks.Impl.TextWriterExpectationLogger(Console.Out);
var mocks = new MockRepository();
var query = new Dictionary<string, string>();
query["q"] = qstring;
var connection = mocks.StrictMock<ISolrConnection>();
var docSerializer = mocks.StrictMock<ISolrDocumentSerializer<TestDocumentWithUniqueKey>>();
var querySerializer = mocks.StrictMock<ISolrQuerySerializer>();
var mlthParser = mocks.StrictMock<ISolrMoreLikeThisHandlerQueryResultsParser<TestDocumentWithUniqueKey>>();
With.Mocks(mocks)
.Expecting(() =>
{
Expect.On(querySerializer)
.Call(querySerializer.Serialize(null))
.IgnoreArguments()
.Return(qstring);
Expect.On(connection)
.Call(connection.Get(null, null))
.IgnoreArguments()
.Return(EmbeddedResource.GetEmbeddedString(GetType(), "Resources.responseWithInterestingTermsDetails.xml"));
Expect.On(mlthParser)
.Call(mlthParser.Parse(null))
.IgnoreArguments()
.Return(new SolrMoreLikeThisHandlerResults<TestDocumentWithUniqueKey>());
})
.Verify(() =>
{
var executer = new SolrQueryExecuter<TestDocumentWithUniqueKey>(null, connection, querySerializer, null, mlthParser);
var solr = new SolrBasicServer<TestDocumentWithUniqueKey>(connection, executer, docSerializer, null, null, null, null, null);
var r = solr.MoreLikeThis(new SolrMoreLikeThisHandlerQuery(new SolrQuery(qstring)), new MoreLikeThisHandlerQueryOptions(new MoreLikeThisHandlerParameters( new string[] { "id" }) { MatchInclude = true }));
});
}