Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do indexing data from database using apache solr with glassfish server on linux?

I want to create a search box in my web app using Apache Lucene and Apache Solr.I am using postgres database and have to do it with java.

As I new to these concepts (solr,lucene), I am struggling with this. I already installed and configured apache Solr with glassfish.Now I dont know how to start with this, Whether I have to cretae a java project in eclipse or I have to use Solr admin GUI.

can any one help me on this?

Thanks in Advance.....

like image 993
Anilkumar Thelukala Avatar asked Dec 06 '12 05:12

Anilkumar Thelukala


People also ask

How is indexing done in Solr?

Solr has a post command in its bin/ directory. Using this command, you can index various formats of files such as JSON, XML, CSV in Apache Solr. Browse through the bin directory of Apache Solr and execute the –h option of the post command, as shown in the following code block.

Where Solr indexes are stored?

Solr (and underlying Lucene) index is a specially designed data structure, stored on the file system as a set of index files. The index is designed with efficient data structures to maximize performance and minimize resource usage.

Can you use Solr as a database?

Yes, you can use SOLR as a database but there are some really serious caveats : SOLR's most common access pattern, which is over http doesnt respond particularly well to batch querying. Furthermore, SOLR does NOT stream data --- so you can't lazily iterate through millions of records at a time.


2 Answers

In order to make data searchable, you have to first index your data. You can use one of the following ways to index data.

  • By using Solr clients such as Solrj
  • If you store your data in relational DB then you can use DataImportHandler
  • By posting XML or Json messages. Check here for documentation.

When new data added you can index it using Solr clients (Solrj). You can also search your data using Solrj or any other client libraries.

You can find other client libraries here.

like image 109
Parvin Gasimzade Avatar answered Sep 21 '22 02:09

Parvin Gasimzade


You can start with Solr DIH to index the data from postgres to Solr.

For more detailed understanding you can refer to :-
how-to-import-data-from-sql-databases-part-1
how-to-import-data-from-sql-databases-part-2
how-to-import-data-from-sql-databases-part-3

like image 27
Jayendra Avatar answered Sep 24 '22 02:09

Jayendra