Support of Apache Solr for .NET

Supported Client Libraries

Library Version Supported
SolrNet Up to:1.1

(tick)

SolrNet.Cloud Up to:1.1

(tick)

Supported Operations

Operations Methods Supported
Insert

SolrNet.ISolrOperations.Add

SolrNet.ISolrOperations.AddAsync

SolrNet.ISolrOperations.AddWithBoost

SolrNet.ISolrOperations.AddWithBoostAsync

SolrNet.ISolrOperations.Extract

SolrNet.ISolrOperations.ExtractAsync

SolrNet.ISolrOperations.AddRange

SolrNet.ISolrOperations.AddRangeAsync

SolrNet.ISolrOperations.AddRangeWithBoost

SolrNet.ISolrOperations.AddRangeWithBoostAsync

SolrNet.ISolrBasicOperations.AddWithBoost

SolrNet.ISolrBasicOperations.AddWithBoostAsync

Select

SolrNet.ISolrReadOnlyOperations.Query

SolrNet.ISolrReadOnlyOperations.QueryAsync

SolrNet.ISolrBasicReadOnlyOperations.Query

SolrNet.ISolrBasicReadOnlyOperations.QueryAsync

SolrNet.ISolrBasicReadOnlyOperations.MoreLikeThis

SolrNet.ISolrBasicReadOnlyOperations.MoreLikeThisAsync

Delete

SolrNet.ISolrOperations.Delete

SolrNet.ISolrOperations.DeleteAsync

SolrNet.ISolrBasicOperations.Delete

SolrNet.ISolrBasicOperations.DeleteAsync

Update

SolrNet.ISolrOperations.AtomicUpdate

SolrNet.ISolrOperations.AtomicUpdateAsync

SolrNet.ISolrBasicOperations.AtomicUpdate

SolrNet.ISolrBasicOperations.AtomicUpdateAsync

Objects

Icon Description

DotNet SolrNet Index

DotNet Unknown SolrNet Index

DotNet SolrNet Client

All links are created between the caller .NET Method objects and DotNet SolrNet Index objects:

Link type Methods Supported
useSelectLink

Query

QueryAsync

useUpdateLink

AtomicUpdate

AtomicUpdateAsync

useInsertLink

Add

AddAsync

AddWithBoost

AddWithBoostAsync

Extract

ExtractAsync

AddRange

AddRangeAsync

AddRangeWithBoost

AddRangeWithBoostAsy

useDeleteLink

Delete

DeleteAsync

What results can you expect?

Some example scenarios are shown below:

DotNet SolrNet Client

using CommonServiceLocator;
using SolrNet;

namespace SOlrStandaloneApp
{
    public class Tests
    {
        public void Setup()
        {
            Startup.Init<Product>("http://localhost:8983/solr/mycore");
        }
    }
}

Select Operation

using CommonServiceLocator;
using SolrNet;

namespace SOlrStandaloneApp
{
    public class Tests
    {    
        [Test]
        public void Query()
        {
            var solr = ServiceLocator.Current.GetInstance<ISolrOperations<Product>>();
            var results = solr.Query(new SolrQueryByField("id", "SP2514N"));
            Assert.AreEqual(1, results.Count);
            Console.WriteLine(results[0].Price);
        }
        
    }
}

Insert Operation

using CommonServiceLocator;
using SolrNet;

namespace SOlrStandaloneApp
{
    public class Tests
    {
        [Test]
        public void Add()
        {
            var p = new Product
            {
                Id = "SP2514N",
                Manufacturer = "Samsung Electronics Co. Ltd.",
                Categories = new[] {
            "electronics",
            "hard drive",
        },
                Price = 92,
                InStock = true,
            };

            var solr = ServiceLocator.Current.GetInstance<ISolrOperations<Product>>();
            solr.Add(p);
            solr.Commit();
        }

    }
}

Update Operation

using CommonServiceLocator;
using SolrNet;

namespace SOlrStandaloneApp
{
    [Test]
        public void AtomicUpdate()
        {
            var p = new Product
            {
                Id = "SP2514N",
                Manufacturer = "Samsung Electronics Co. Ltd.",
                Categories = new[] {
            "electronics",
            "hard drive",
        },
                Price = 92,
                InStock = true,
            };

            var solr = ServiceLocator.Current.GetInstance<ISolrOperations<Product>>();
            solr.AtomicUpdate(p,null);
            solr.Commit();
        }

    }
}

Delete Operation

using CommonServiceLocator;
using SolrNet;

namespace SOlrStandaloneApp
{
        [Test]
        public void Remove()
        {
            var p = new Product
            {
                Id = "SP2514N",
                Manufacturer = "Samsung Electronics Co. Ltd.",
                Categories = new[] {
            "electronics",
            "hard drive",
        },
                Price = 92,
                InStock = true,
            };

            var solr = ServiceLocator.Current.GetInstance<ISolrOperations<Product>>();
            solr.Delete(p);
            solr.Commit();
        }
}

Known Limitations

  • Startup.Init and Startup.InitAsync are only API currently supported for server connection of SolrNet and SolrNet Cloud.