public void Parse() {
     var mapper = new AttributesMappingManager();
     var fieldParser = new DefaultFieldParser();
     var docVisitor = new DefaultDocumentVisitor(mapper, fieldParser);
     var docParser = new SolrDocumentResponseParser<Product>(mapper, docVisitor, new SolrDocumentActivator<Product>());
     var p = new MoreLikeThisHandlerMatchResponseParser<Product>(docParser);
     var mltResults = new SolrMoreLikeThisHandlerResults<Product>();
     var xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.responseWithMLTHandlerMatch.xml");
     p.Parse(xml, mltResults);
     Assert.IsNotNull(mltResults.Match);
 }
Example #2
0
        private void SetupSolr() {
            Startup.InitContainer();

            Startup.Container.Remove<IReadOnlyMappingManager>();
            var mapper = new MappingManager();
            mapper.Add(typeof (Entity).GetProperty("Description"), "name");
            mapper.Add(typeof (Entity).GetProperty("Id"), "id");
            mapper.Add(typeof (Entity).GetProperty("Tags"), "cat");
            Startup.Container.Register<IReadOnlyMappingManager>(c => mapper);

            Startup.Container.Remove<ISolrDocumentPropertyVisitor>();
            var propertyVisitor = new DefaultDocumentVisitor(mapper, Startup.Container.GetInstance<ISolrFieldParser>());
            Startup.Container.Register<ISolrDocumentPropertyVisitor>(c => propertyVisitor);

            Startup.Init<Entity>("http://localhost:8983/solr");
            var solr = ServiceLocator.Current.GetInstance<ISolrOperations<Entity>>();
            solr.Delete(SolrQuery.All).Commit();
        }
Example #3
0
        private static void SetupSolr() {
            var connection = new SolrConnection(_httpSolrTest);
            Startup.InitContainer();

            Startup.Container.Remove<IReadOnlyMappingManager>();

            var mapper = new MappingManager();
            Mappings(mapper);
            Startup.Container.Register<IReadOnlyMappingManager>(c => mapper);

            Startup.Container.Remove<ISolrDocumentPropertyVisitor>();
            var propertyVisitor = new DefaultDocumentVisitor(mapper, Startup.Container.GetInstance<ISolrFieldParser>());
            Startup.Container.Register<ISolrDocumentPropertyVisitor>(c => propertyVisitor);

            Startup.Init<Child>(connection);
            Startup.Init<Parent>(connection);
            Startup.Init<Dictionary<string,object>>(connection);
            Startup.Container.RemoveAll<ISolrDocumentResponseParser<Dictionary<string, object>>>();
            Startup.Container.Register<ISolrDocumentResponseParser<Dictionary<string, object>>>(c => new SolrDictionaryDocumentResponseParser(c.GetInstance<ISolrFieldParser>()));

            var solr = ServiceLocator.Current.GetInstance<ISolrOperations<Child>>();

            solr.Delete(SolrQuery.All);
            solr.Commit();
        }