简体   繁体   English

如何使用Solrnet搜索多个馆藏? C#

[英]How to use Solrnet to search multiple collection? C#

Q1. Q1。 How to use Solrnet to search multiple collection? 如何使用Solrnet搜索多个馆藏?

Q2. Q2。 I created a method to add data to Solr, And if i want to dynamic assign sechma add data to Solr, how to modify it? 我创建了一种向Solr添加数据的方法,并且如果我想动态分配sechma向Solr添加数据,如何对其进行修改?

     public void SolrFeeder(SchemaFieldList DataList)
    {
        var solrFacility = new SolrNetFacility(SolrServer);
        var container = new WindsorContainer();
        container.AddFacility("solr", solrFacility);
        var solr = container.Resolve<ISolrOperations<SchemaField>>();
        foreach (var item in DataList.SchemaFieldList)
        {
            solr.Add(item);
        }
        solr.Commit();
    }

The standard syntax for searching across collections is to provide the name of the collections in the query - ie if you're querying collection1 , you can still append a parameter named collection which contains a list of the collections you want to search, collection=collection1,collection2,collection3 . 用于搜索集合的标准语法是在查询中提供集合的名称-即,如果要查询collection1 ,您仍然可以附加一个名为collection的参数,该参数包含要搜索的集合的列表, collection=collection1,collection2,collection3

You can use the syntax for "Additional Parameters" in SolrNet to add custom arguments to a query: 您可以在SolrNet中使用“附加参数”的语法将自定义参数添加到查询中:

ISolrOperations<Product> solr = ...
var products = solr.Query(SolrQuery.All, new QueryOptions {
    ExtraParams = new Dictionary<string, string> {
        {"collection", "collection1,collection2,collection3"}
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM