Wednesday, July 29, 2015

ELASTICSEARCH JDBC CONNECTOR

ELASTICSEARCH JDBC CONNECTOR


1) Check the dependency and download appropriate JDBC connector version code as per your elasticsearch version.

2) Download the code from below location:

3) Compile the code using “mvn clean install”. It will create a jar file in target folder.

4) Copy the jar file into elasticsearch lib folder.

5) Download the JDBC importer distribution from below location

6) unpack
unzip elasticsearch-jdbc-<version>-dist.zip

7) This will be our $JDBC_IMPORTER_HOME

8) Set the below path 
#Elastic Search
$> ES_HOME=/Users/jayeshbhoyar/Desktop/Programs/elasticsearchinstance/
$> export ES_HOME

# JDBC_IMPORTER_HOME
$> JDBC_IMPORTER_HOME=/Users/jayeshbhoyar/Desktop /Programs/elasticsearchinstance/elasticsearchjdbc1.5.2.0/
$> export JDBC_IMPORTER_HOME

9) Download the JDBC driver jar file from vendor site and copy it in “ES_HOME/lib” and “JDBC_IMPORTER_HOME/lib” folders

10) Go to “JDBC_IMPORTER_HOME” Folder and execute the below command:

bin=$JDBC_IMPORTER_HOME/bin 
lib=$JDBC_IMPORTER_HOME/lib 

echo '{     
"type" : "jdbc",     
"jdbc" : {         
"url" : "jdbc:mysql://localhost:3306/test",         
"user" : "",         "
password" : "",         
"sql" : "select *, id as _id from orders"     
}' | java \        
-cp "${lib}/*" \        
-Dlog4j.configurationFile=${bin}/log4j2.xml \        
org.xbib.tools.Runner \        
org.xbib.tools.JDBCImporter


It will start pulling the records from orders table and insert it into elasticsearch.

Sample File:
{
    "type" : "jdbc",
    "bulk_size" : 1000,
"max_bulk_requests" : 50,
"bulk_flush_interval" : "10s",
"max_concurrent_bulk_requests" : 16,
"max_bulk_actions" : 1000,
    "jdbc" : {
        "url" : "jdbc:oracle:thin:@hostname:port:SID",
        "driver": "oracle.jdbc.OracleDriver",
        "user" : "username",
        "fetchsize" : 1000,
        "password" : "password",
        "sql" : "SELECT * FROM ABC”,
        "index" : "INDEXNAME",
        "type" : "INDEXTYPE",
        "index_settings": {
            "index": {
                "refresh_interval": "5s"
            }
        } ,
        "max_bulk_actions" : 1000,
    "metrics" : {
        "enabled" : true,
        "interval" : "1m",
        "logger" : {
            "plain" : true,
            "json" : false
        }
    },
        "max_concurrent_bulk_requests" : 16,
        "connection_properties" : {
            "oracle.jdbc.TcpNoDelay" : false,
            "useFetchSizeWithLongColumn" : false,
            "oracle.net.CONNECT_TIMEOUT" : 10000,
            "oracle.jdbc.ReadTimeout" : 50000
        },
        "elasticsearch" : {
         "cluster" : "CLUSTERNAME",
         "host" : "ELASTICSEARCHHOSTNAME",
         "port" : 9300
    }
    }
}

For more settings and more information visit below link.


Hope this Helps!!!!
Jayesh Bhoyar

Reference:
https://github.com/jprante/elasticsearch-jdbc

Check More Articles on ElasticSearch:
http://technical-fundas.blogspot.com/2015/07/elasticsearch-bigdesk-plugin.html

Saturday, July 18, 2015

ElasticSearch BigDesk Plugin

ElasticSearch BigDesk Plugin

Bigdesk Plugin makes it very easy to see how your Elasticsearch cluster is doing. 
Just install it as an Elasticsearch plugin, download locally or run online from the web, 
then point it to the Elasticsearch node REST endpoint and have fun.

To install Bigdesk as an Elasticsearch plugin on a particular Elasticsearch node, 

navigate to the node installation folder i.e. ES_HOME and run the following command:

bin/plugin -install lukas-vlcek/bigdesk



Then you can navigate your web browser to 

http://HOSTNAME:PORT/_plugin/bigdesk/

Example:

http://localhost:9200/_plugin/bigdesk/














Reference:

Check More Articles on Elasticsearch:
http://technical-fundas.blogspot.com/2015/07/elasticsearch-jdbc-connector.html
http://technical-fundas.blogspot.com/2014/08/elasticsearch-install-and-access-head.html

Sunday, October 19, 2014

Explaining Iaas, Paas, SaaS

Very well explained IaaS/PaaS/SaaS with a simple Pizza example.

No matter which service we use; ultimately we have to pay for the Service that we are using.






Sunday, August 17, 2014

[elasticsearch] Install and access head plugin in elasticsearch

There are many customized plugins that comes with elasticsearch. In this article we will see how to install and then how to use the head plugin with elasticsearch.


Here are few steps that we need to follow:

Step1:
To install head plugin from site use following command:
bin/plugin --install mobz/elasticsearch-head
 You will be able to install the plugin using above only when you have internet connectivity and your firewall alows you to download and install

Else you can manually download the elasticsearch-head.zip plugin from https://github.com/mobz/

Run the following command
bin/plugin --url file:///d:\elasticsearch-head.zip --install mobz/elasticsearch-head

Step 2:
Restart the elasticsearch instance and you will be able to access it as

http://localhost:9200/_plugin/head/

Sunday, August 10, 2014

[SOLR] How to join fl default parameters and request parameters?



If I have set of fields, specified in fl of some SearchRequestHandler configuration in xml, then fl specified in query request parameter will override fl specified in SearchRequestHandler configuration in xml.
I want that SOLR to do Join of fl parameters from query and from SearchRequestHandler instead of overriding it.
For example:
If in query I have fl=field1,field2 and in SearchRequestHandler configuration; I have fl=field3,field1 then join of these two as fl=field1,field2,field3. 
For this issue you can use following solution:
You can use <lst name="appends"> in your requestHandler definition to make Solr append the values to the query instead of replacing them. Since fl can be added several times to the same request, this works as you're extending the list of fields to retrieve.


<requestHandler name="/select" class="solr.SearchHandler">
    <lst name="appends">
        <str name="fl">cat</str>
    </lst>
</requestHandler>



This solution will help you when you have too many fl fields that needs to defined and few of them changes as per the query.

Sunday, August 3, 2014

[SOLR] Implementing Facet with multiple categories along with their count

How can we facet on more than two categories ( ‘project’ and ‘type’ as discussed below) and at the same time get the combination facets and their count.

Example : http://search-lucene.com/

When you open URL, http://search-lucene.com/?q=facets you can see the facets on right hand side as 'Project','type','date','author' and their corresponding values with count in brackets.

For instance, let’s say you select 'solr(32857)' under 'Project' facet, still we can see other values under 'Project' facet like ElasticSearch etc. along with their respective count. 







Further when we Select 'mail # user(23138)' under “type” section , again we can see other values under “type” section with their corresponding count in brackets and their corresponding values in “Project” facet gets changed accordingly (namely the count ). 




Observe how solr(32857) changed to Solr (22969) post selection of mail # user along with the other values of ‘Project’ (like ElasticSearch etc.) and ‘type’ (issue, javadoc etc.,) with a change in their count values.

To achieve similar functionality you can use following solution:

Use Tagging and excluding Filters: http://wiki.apache.org/solr/SimpleFacetParameters#Tagging_and_excluding_Filters

select?q=solr%20facets&fq={!tag=projectTag}Project:"solr"&fq={!tag=typeTag}type:"mail # user"&facet=true&facet.field={!ex=projectTag}project&facet.field={!ex=typeTag}type&wt=json&indent=true

Using the above solution I am able to implement the faceting solution mentioned in above website using SOLR.

Hope this is useful information for your all!!!!



Sunday, July 27, 2014

Crawl your website using Nutch Crawler without Indexing the HTML content into SOLR

This article will help you in resolving following issue:

1) If you want to crawl the website using Nutch Crawler without indexing the HTML content into SOLR here are the changes that you need to perform the crawl script of nutch package.

You need to remove the following piece of code:

SOLRURL="$3"

if [ "$SOLRURL" = "" ]; then echo "Missing SOLRURL : crawl <seedDir> <crawlDir> <solrURL> <numberOfRounds>" exit -1;fi


echo "Indexing $SEGMENT on SOLR index -> $SOLRURL" $bin/nutch index -D solr.server.url=$SOLRURL $CRAWL_PATH/crawldb -linkdb $CRAWL_PATH/linkdb $CRAWL_PATH/segments/$SEGMENT if [ $? -ne 0 ]
then exit $?
fi

echo "Cleanup on SOLR index -> $SOLRURL" $bin/nutch clean -D solr.server.url=$SOLRURL $CRAWL_PATH/crawldb if [ $? -ne 0 ]
then exit $?
fi

Hope This Helps!!!

Password Protected Solr Admin Page

As we all know Solr Admin Page is not password protected and anyone can get into Solr Admin Page. However this article will ...