At present there are 2 main players in the full text searches for applications. Solr and Elasticsearch. Both are built using Lucene.
There’s a lot of dicussion about which is the best, but for me, Elasticsearch provides some better features and seems to be growing faster. I decided to choose Elasticsearch because you require no schema for the documents and can you can have nested documents. Here’s a set of links showing/explaining the pros and cons:
SOLR or Elasticsearch
http://solr-vs-elasticsearch.com/
http://www.elasticsearchtutorial.com/elasticsearch-vs-solr.html
http://stackoverflow.com/questions/10213009/solr-vs-elasticsearch
http://www.ymc.ch/en/why-we-chose-solr-4-0-instead-of-elasticsearch
Installing Elasticsearch
Download the required zip.
http://www.elasticsearch.org/download/
Unpack it and save it to your file system.
Set your JAME_HOME variable if not already set. This should be set to the latest installed jdk.
Now start your service:
\elasticsearch-0.90.10\bin\elasticsearch.bat
This just starts it in the command line. You can also install it as a service if required.
Now check if it’s ok. Send a GET http://localhost:9200/_nodes/process?pretty in fiddler.
You should recieve a json answer:
Install Elastic HQ
Download the required zip and unpack:
http://www.elastichq.org/gettingstarted.html
Open the index.html and connect to http://localhost:9200
Create a index:
http://localhost:9200/<index>/<type>/%5B<id>%5D
We’ll use the log4net.ElasticSearch json.
Or we can create a second index:
PUT http://localhost:9200/myfirstindex/demotype/1
{
"name": "damienbod",
"reason": "To say hello",
"place": "Switzerland"
}
And now the indexes can be viewed in the HQ:
Create a .NET client:
In the first example, a log4net is used and logged to the elasticsearch search engine. We mainly follow the instructions from Log4net.elasticsearch. Thanks for this.
Here’s the log4net config:
<log4net> <appender name="ElasticSearchAppender" type="log4net.ElasticSearch.ElasticSearchAppender, log4net.ElasticSearch"> <!-- for .NET 40 <appender name="ElasticSearchAppender" type="log4net.ElasticSearch.ElasticSearchAppender, log4net.ElasticSearch.Net40">--> <layout type="log4net.Layout.PatternLayout,log4net"> <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p %c{1}:%L - %m%n" /> </layout> <connectionString value="Server=localhost;Index=log;Port=9200"/> </appender> <root> <level value="ALL"/> <appender-ref ref="ElasticSearchAppender" /> </root> </log4net>
using log4net; namespace ConsoleElasticSearch { class Program { private static readonly ILog _log = LogManager.GetLogger(typeof(Program)); static void Main(string[] args) { for (int i = 1; i < 100; i++) { _log.Info("console test log " + i); } } } }
Here’s the sample application:
https://github.com/damienbod/ElasticSearchLog4NetExample
So now we’re ready to start learning how to use Elasticsearch. For how to setup the server properly in a production enviroment, refer to elasticsearch or buy a book.
MVC .NET Elasticsearch Tutorials:
Part 1: ElasticsearchCRUD introduction
Part 2: MVC application search with simple documents using autocomplete, jQuery and jTable
Part 3: MVC Elasticsearch CRUD with nested documents
Part 4: Data Transfer from MS SQL Server using Entity Framework to Elasticsearch
Part 5: MVC Elasticsearch with child, parent documents
Part 6: MVC application with Entity Framework and Elasticsearch
Links:
http://nest.azurewebsites.net/
https://github.com/jptoto/log4net.ElasticSearch
http://joelabrahamsson.com/elasticsearch-101/
http://exploringelasticsearch.com/book/an-overview/what-is-elasticsearch.html
Can you help me in Facet Navigation in Web page in .dot net