Tuesday, March 17, 2015

create your own search engine with solr

1- download solr from http://lucene.apache.org/solr/mirrors-solr-latest-redir.html

2- extract and run solr instance
~$ unzip solr-4.10.2.zip
~$ cd solr-4.10.2

~$ bin/solr start -e cloud -noprompt

now we can access it with url http://localhost:8983/solr/

3- index our documents directories or our intranet
it supports many file format such as HTML, PDF, Microsoft Office formats (such as MS Word), plain text and many other formats.

example: index document in directories /home/user/docs and /home/user/tips
~$ java -classpath dist/solr-core-4.10.2.jar  -Dauto=yes -Dc=gettingstarted -Ddata=files -Drecursive=yes org.apache.solr.util.SimplePostTool /home/user/docs/

~$ java -classpath dist/solr-core-4.10.2.jar  -Dauto=yes -Dc=gettingstarted -Ddata=files -Drecursive=yes org.apache.solr.util.SimplePostTool /home/user/tips

4- search for our document use url http://localhost:8983/solr/#/collection1/query
the result can be json, python, xml, php, csv, or ruby, it's up to our choice




 

No comments:

Post a Comment