本文整理汇总了C#中SolrNetFacility类的典型用法代码示例。如果您正苦于以下问题:C# SolrNetFacility类的具体用法?C# SolrNetFacility怎么用?C# SolrNetFacility使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SolrNetFacility类属于命名空间,在下文中一共展示了SolrNetFacility类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddCoreFromXML
public void AddCoreFromXML()
{
var solrFacility = new SolrNetFacility();
var container = new WindsorContainer(new XmlInterpreter(new StaticContentResource(@"<castle>
<facilities>
<facility id='solr'>
<solrURL>http://localhost:8983/solr/defaultCore</solrURL>
<cores>
<core id='core0-id'>
<documentType>Castle.Facilities.SolrNetIntegration.Tests.Tests+Document, Castle.Facilities.SolrNetIntegration.Tests</documentType>
<url>http://localhost:8983/solr/core0</url>
</core>
<core id='core1-id'>
<documentType>Castle.Facilities.SolrNetIntegration.Tests.Tests+Document, Castle.Facilities.SolrNetIntegration.Tests</documentType>
<url>http://localhost:8983/solr/core1</url>
</core>
<core id='core2-id'>
<documentType>Castle.Facilities.SolrNetIntegration.Tests.Tests+Core1Entity, Castle.Facilities.SolrNetIntegration.Tests</documentType>
<url>http://localhost:8983/solr/core1</url>
</core>
</cores>
</facility>
</facilities>
</castle>")));
container.AddFacility("solr", solrFacility);
TestCores(container);
}
示例2: ReplacingMapper
public void ReplacingMapper() {
var mapper = new MReadOnlyMappingManager();
var solrFacility = new SolrNetFacility("http://localhost:8983/solr") {Mapper = mapper};
var container = new WindsorContainer();
container.AddFacility("solr", solrFacility);
var m = container.Resolve<IReadOnlyMappingManager>();
Assert.AreSame(m, mapper);
}
示例3: AddCore
public void AddCore()
{
const string core0url = "http://localhost:8983/solr/core0";
const string core1url = "http://localhost:8983/solr/core1";
var solrFacility = new SolrNetFacility("http://localhost:8983/solr/defaultCore");
solrFacility.AddCore("core0-id", typeof(Document), core0url);
solrFacility.AddCore("core1-id", typeof(Document), core1url);
solrFacility.AddCore("core2-id", typeof(Core1Entity), core1url);
var container = new WindsorContainer();
container.AddFacility("solr", solrFacility);
TestCores(container);
}
示例4: DictionaryDocument_add
public void DictionaryDocument_add()
{
var solrFacility = new SolrNetFacility("http://localhost:8983/solr");
var container = new WindsorContainer();
container.AddFacility("solr", solrFacility);
var solr = container.Resolve<ISolrOperations<Dictionary<string, object>>>();
solr.Add(new Dictionary<string, object> {
{"id", "ababa"},
{"manu", "who knows"},
{"popularity", 55},
{"timestamp", DateTime.UtcNow},
});
}
示例5: DictionaryDocument
public void DictionaryDocument()
{
var solrFacility = new SolrNetFacility("http://localhost:8983/solr");
var container = new WindsorContainer();
container.AddFacility("solr", solrFacility);
var solr = container.Resolve<ISolrOperations<Dictionary<string, object>>>();
var results = solr.Query(SolrQuery.All);
Assert.GreaterThan(results.Count, 0);
foreach (var d in results)
{
Assert.GreaterThan(d.Count, 0);
foreach (var kv in d)
Console.WriteLine("{0}: {1}", kv.Key, kv.Value);
}
}
示例6: SetConnectionTimeoutInMulticore
public void SetConnectionTimeoutInMulticore()
{
const string core0url = "http://localhost:8983/solr/core0";
const string core1url = "http://localhost:8983/solr/core1";
var solrFacility = new SolrNetFacility("http://localhost:8983/solr/defaultCore");
solrFacility.AddCore("core0-id", typeof(Document), core0url);
solrFacility.AddCore("core1-id", typeof(Document), core1url);
solrFacility.AddCore("core2-id", typeof(Core1Entity), core1url);
var container = new WindsorContainer();
container.Kernel.ComponentModelCreated += model => {
if (model.Implementation == typeof(SolrConnection))
model.Parameters.Add("Timeout", "2000");
};
container.AddFacility("solr", solrFacility);
var allTimeouts = container.ResolveAll<ISolrConnection>().Cast<SolrConnection>().Select(x => x.Timeout);
foreach (var t in allTimeouts)
Assert.AreEqual(2000, t);
}
示例7: Resolve_ISolrOperations
public void Resolve_ISolrOperations()
{
var solrFacility = new SolrNetFacility("http://localhost:8983/solr");
var container = new WindsorContainer();
container.AddFacility("solr", solrFacility);
container.Resolve<ISolrOperations<Document>>();
}
示例8: MultiCore
public void MultiCore()
{
const string core0url = "http://localhost:8983/solr/core0";
const string core1url = "http://localhost:8983/solr/core1";
var solrFacility = new SolrNetFacility(core0url);
var container = new WindsorContainer();
container.AddFacility("solr", solrFacility);
// override core1 components
const string core1Connection = "core1.connection";
container.Register(Component.For<ISolrConnection>().ImplementedBy<SolrConnection>().Named(core1Connection)
.Parameters(Parameter.ForKey("serverURL").Eq(core1url)));
container.Register(Component.For(typeof (ISolrBasicOperations<Core1Entity>), typeof (ISolrBasicReadOnlyOperations<Core1Entity>))
.ImplementedBy<SolrBasicServer<Core1Entity>>()
.ServiceOverrides(ServiceOverride.ForKey("connection").Eq(core1Connection)));
container.Register(Component.For<ISolrQueryExecuter<Core1Entity>>().ImplementedBy<SolrQueryExecuter<Core1Entity>>()
.ServiceOverrides(ServiceOverride.ForKey("connection").Eq(core1Connection)));
// assert that everything is correctly wired
container.Kernel.DependencyResolving += (client, model, dep) => {
if (model.TargetType == typeof(ISolrConnection)) {
if (client.Services.Contains(typeof(ISolrBasicOperations<Core1Entity>)) || client.Services.Contains(typeof(ISolrQueryExecuter<Core1Entity>)))
Assert.AreEqual(core1url, ((SolrConnection) dep).ServerURL);
if (client.Services.Contains(typeof(ISolrBasicOperations<Document>)) || client.Services.Contains(typeof(ISolrQueryExecuter<Document>)))
Assert.AreEqual(core0url, ((SolrConnection) dep).ServerURL);
}
};
container.Resolve<ISolrOperations<Core1Entity>>();
container.Resolve<ISolrOperations<Document>>();
}
示例9: MappingValidationManager
public void MappingValidationManager()
{
var solrFacility = new SolrNetFacility("http://localhost:8983/solr");
var container = new WindsorContainer();
container.AddFacility("solr", solrFacility);
var validator = container.Resolve<IMappingValidator>();
}
示例10: DictionaryDocument_Serializer
public void DictionaryDocument_Serializer()
{
var solrFacility = new SolrNetFacility("http://localhost:8983/solr");
var container = new WindsorContainer();
container.AddFacility("solr", solrFacility);
var serializer = container.Resolve<ISolrDocumentSerializer<Dictionary<string, object>>>();
Assert.IsInstanceOfType<SolrDictionarySerializer>(serializer);
}
示例11: ResponseParsers
public void ResponseParsers()
{
var solrFacility = new SolrNetFacility("http://localhost:8983/solr");
var container = new WindsorContainer();
container.AddFacility("solr", solrFacility);
var parser = container.Resolve<ISolrQueryResultParser<Document>>() as SolrQueryResultParser<Document>;
var field = parser.GetType().GetField("parsers", BindingFlags.NonPublic | BindingFlags.Instance);
var parsers = (ISolrResponseParser<Document>[]) field.GetValue(parser);
Assert.AreEqual(10, parsers.Length);
foreach (var t in parsers)
Console.WriteLine(t);
}
示例12: ReplacingMapper
public void ReplacingMapper()
{
var mapper = MockRepository.GenerateMock<IReadOnlyMappingManager>();
var solrFacility = new SolrNetFacility(_solrUrl) {Mapper = mapper};
var container = new WindsorContainer();
container.AddFacility("solr", solrFacility);
var m = container.Resolve<IReadOnlyMappingManager>();
Assert.AreSame(m, mapper);
}
示例13: DictionaryDocument_ResponseParser
public void DictionaryDocument_ResponseParser()
{
var solrFacility = new SolrNetFacility("http://localhost:8983/solr");
var container = new WindsorContainer();
container.AddFacility("solr", solrFacility);
var parser = container.Resolve<ISolrDocumentResponseParser<Dictionary<string, object>>>();
Assert.That(parser, Is.InstanceOfType<SolrDictionaryDocumentResponseParser>());
}
示例14: Can_add_selecte_and_remove_document
public void Can_add_selecte_and_remove_document()
{
var solrFacility = new SolrNetFacility(_solrUrl);
var container = new WindsorContainer();
container.AddFacility("solr", solrFacility);
var solr = container.Resolve<ISolrOperations<Dictionary<string, object>>>();
var dictionary = new Dictionary<string, object> {
{"id", "ababa"},
{"manu", "who knows"},
{"popularity", 55},
{"timestamp", DateTime.UtcNow},
};
solr.Add(dictionary);
solr.Commit();
var results = solr.Query(SolrQuery.All);
Assert.That(results.Count, Is.GreaterThan(0));
foreach (var d in results) {
Assert.That(d.Count, Is.GreaterThan(0));
foreach (var kv in d) {
Console.WriteLine("{0}: {1}", kv.Key, kv.Value);
break;
}
break;
}
solr.Delete("ababa");
}
示例15: Container_has_ISolrDocumentPropertyVisitor
public void Container_has_ISolrDocumentPropertyVisitor()
{
var solrFacility = new SolrNetFacility("http://localhost:8983/solr");
var container = new WindsorContainer();
container.AddFacility("solr", solrFacility);
container.Resolve<ISolrDocumentPropertyVisitor>();
}