当前位置: 首页>>代码示例>>C#>>正文


C# SolrBasicServer.MoreLikeThis方法代码示例

本文整理汇总了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);
        }
开发者ID:rivuc,项目名称:SolrNet-1,代码行数:29,代码来源:SolrOperationsTests.cs

示例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 }));
                });
        }
开发者ID:paulcarroll,项目名称:SolrNet,代码行数:38,代码来源:SolrOperationsTests.cs


注:本文中的SolrBasicServer.MoreLikeThis方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。