Reputation: 67
Q1. How to use Solrnet to search multiple collection?
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?
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();
}
Upvotes: 0
Views: 782
Reputation: 52822
The standard syntax for searching across collections is to provide the name of the collections in the query - i.e. 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
.
You can use the syntax for "Additional Parameters" in SolrNet to add custom arguments to a query:
ISolrOperations<Product> solr = ...
var products = solr.Query(SolrQuery.All, new QueryOptions {
ExtraParams = new Dictionary<string, string> {
{"collection", "collection1,collection2,collection3"}
}
});
Upvotes: 3