While you are separating your data when you are adding it to the index and are querying based a known type on the client, you are storing it all in the same schema in Solr and are not specifying any way to distinguish item from category records in Solr. I would recommend you modify your schema to include a type field which can just be a simple string, such as the following:
<field name="type" type="string" indexed="true" stored="true" />
Then you will need to the add the type field to your SolrSearchEntity base class and set it appropriately in the Category and Item classes. Something like the following:
[Serializable]
[XmlRoot(ElementName = "SolrSearchEntity", Namespace = "")]
[DataContract(Name = "SolrSearchEntity", Namespace = "")]
public class SolrSearchEntity
{
[XmlElement(ElementName = "Id")]
[DataMember(Name = "Id", IsRequired = true)]
[SolrUniqueKey("id")]
public string Id { get; set; }
[XmlElement(ElementName = "Name")]
[DataMember(Name = "Name", IsRequired = true)]
[SolrField("name")]
public string Name { get; set; }
[SolrField("type")]
public string Type {get; set;}
}
public class Category : SolrSearchEntity
{
public Category()
{
Type = "Category";
}
}
public class Item : SolrSearchEntity
{
public Item()
{
Type = "Item";
}
}
Then when you run a search if you want to limit your query by a specific type, you can add a filter query like this to only search Items:
var entities = ItemStoreManager<Category>.Search(keyword);
new SolrBaseRepository.Instance<T>().Start();
var solr = ServiceLocator.Current.GetInstance<ISolrOperations<T>>();
var options = new QueryOptions{
FilterQueries = new ISolrQuery[] { new SolrQueryByField("type","Item")}};
var results = solr.Query(keyword, options);
Additionally, be careful that your id values are not overlapping in your database as that will cause you to only store one instance of an entity (either the category or item, whichever is indexed last).
Finally, I feel your current indexing strategy is sound and would not recommend the use of the DIH. IMO, you will have more control and flexibility using the SolrNet client library. I have had issues with the Data Import Handlers in the past and found the use of SolrNet to much easier to manage and maintain.