RSS

Monthly Archives: July 2015

Install mod_deflate in Ubunut Apache 2.2

By: pontikis.net

Installation

In latest Debian version (Debian 6 or Squeeze), mod_deflate is installed and enabled. If not:

a2enmod deflate
service apache2 restart
Edit website configutation file, for example:
nano /etc/apache2/sites-available/www.pontikis.net
add the following lines:
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|ico|png)$ \ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ \no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

Explanation of above Apache directives:

  • Line 1: Enable gzip compression
  • Line 2: Do not compress images
  • Line 3: Do not compress already compressed files
  • Line 4: Do not compress pdf
  • Line 6-8: Some exceptions for old browsers

That’s all. Don’t forget to restart Apache.

As an alternative, you can use an .htaccess file in your webroot directory (with the same Apache directives).

Advertisements
 
Leave a comment

Posted by on July 30, 2015 in Apache2, Application Server

 

SQL Server in Solr using Data Import Handler

By: 

MS SQL Server connector

Download Microsoft JDBC Driver 4.0 for SQL Server from: http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774

copy file ‘sqljdbc4.jar’ to ‘contrib/dataimporthandler/lib’

solrconfig.xml

copy solrconfig.xml from an existing collection. Find my version of solrconfig.xml below in this gist.

edit solrconfig.xml by adding:

<lib dir="../../contrib/dataimporthandler/lib" regex=".*\.jar" />
<lib dir="../../dist/" regex="solr-dataimporthandler-.*\.jar" />

Make sure that ‘dist’ folder contains two files for data import handler:

  • solr-dataimporthandler-4.10.2.jar
  • solr-dataimporthandler-extras-4.10.2.jar

add these lines to solrconfig.xml:

<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
    <lst name="defaults">
    <str name="config">data-config.xml</str>
    </lst>
</requestHandler>

data-config.xml for SQL Server database

<dataConfig>
  <dataSource type="JdbcDataSource" 
              driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" 
              url="jdbc:sqlserver://servername\instancename;databaseName=mydb"   
              user="sa" 
              password="mypass"/>
  <document>
    <entity name="product"  
      pk="id"
      query="select id,name from products"
      deltaImportQuery="SELECT id,name from products WHERE id='${dih.delta.id}'"
      deltaQuery="SELECT id FROM products  WHERE updated_at > '${dih.last_index_time}'"
      >
       <field column="id" name="id"/>
       <field column="name" name="name"/>       
    </entity>
  </document>
</dataConfig>

Copy from: https://gist.github.com/maxivak/3e3ee1fca32f3949f052

 

 
Leave a comment

Posted by on July 21, 2015 in Application Server, Solr

 

How To Install Solr 5.2.1 on Ubuntu 14.04

By: Koen Vlaswinkel

Written in collaboration with Solr

Introduction

Solr is a search engine platform based on Apache Lucene. It is written in Java and uses the Lucene library to implement indexing. It can be accessed using a variety of REST APIs, including XML and JSON. This is the feature list from their website:

  • Advanced Full-Text Search Capabilities
  • Optimized for High Volume Web Traffic
  • Standards Based Open Interfaces – XML, JSON and HTTP
  • Comprehensive HTML Administration Interfaces
  • Server statistics exposed over JMX for monitoring
  • Linearly scalable, auto index replication, auto failover and recovery
  • Near Real-time indexing
  • Flexible and Adaptable with XML configuration
  • Extensible Plugin Architecture

In this article, we will install Solr using its binary distribution.

Prerequisites

To follow this tutorial, you will need:

Step 1 — Installing Java

Solr requires Java, so in this step, we will install it.

The complete Java installation process is thoroughly described in this article, but we’ll use a slightly different process.

First, use apt-get to install python-software-properties:

  • sudo apt-get install python-software-properties

Instead of using the default-jdk or default-jre packages, we’ll install the latest version of Java 8. To do this, add the unofficial Java installer repository:

  • sudo add-apt-repository ppa:webupd8team/java

You will need to press ENTER to accept adding the repository to your index.

Then, update the source list:

  • sudo apt-get update

Last, install Java 8 using apt-get. You will need to agree to the Oracle Binary Code License Agreement for the Java SE Platform Products and JavaFX.

  • sudo apt-get install oracle-java8-installer

Step 2 — Installing Solr

In this section, we will install Solr 5.2.1. We will begin by downloading the Solr distribution.

First, find a suitable mirror on this page. Then, copy the link of solr-5.2.1.tgz from the mirror. For example, we’ll use http://apache.mirror1.spango.com/lucene/solr/5.2.1/.

Then, download the file in your home directory:

Next, extract the service installation file:

  • tar xzf solr-5.2.1.tgz solr-5.2.1/bin/install_solr_service.sh –strip-components=2

And install Solr as a service using the script:

  • sudo bash ./install_solr_service.sh solr-5.2.1.tgz

Finally, check if the server is running:

  • sudo service solr status

You should see an output that begins with this:

Solr status output
Found 1 Solr nodes: 

Solr process 2750 running on port 8983

. . .

Step 3 — Creating a Collection

In this section, we will create a simple Solr collection.

Solr can have multiple collections, but for this example, we will only use one. To create a new collection, use the following command. We run it as the Solr user in this case to avoid any permissions errors.

  • sudo su – solr -c “/opt/solr/bin/solr create -c gettingstarted -n data_driven_schema_configs”

In this command, gettingstarted is the name of the collection and -n specifies the configset. There are 3 config sets supplied by Solr by default; in this case, we have used one that is schemaless, which means that any field can be supplied, with any name, and the type will be guessed.

You have now added the collection and can start adding data. The default schema has only one required field: id. It has no other default fields, only dynamic fields. If you want to have a look at the schema, where everything is explained clearly, have a look at the file/opt/solr/server/solr/gettingstarted/conf/schema.xml.

Step 4 — Adding and Querying Documents

In this section, we will explore the Solr web interface and add some documents to our collection.

When you visit http://your_server_ip:8983/solr using your web browser, the Solr web interface should appear:

Solr Web Interface

The web interface contains a lot of useful information which can be used to debug any problems you encounter during use.

Collections are divided up into cores, which is why there are a lot of references to cores in the web interface. Right now, the collection gettingstarted only contains one core, named gettingstarted. At the left-hand side, the Core Selector pull down menu is visible, in which you’ll be able to selectgettingstarted to view more information.

After you’ve selected the gettingstarted core, select Documents. Documents store the real data that will be searchable by Solr. Because we have used a schemaless configuration, we can use any field. Let’sl add a single document with the following example JSON representation by copying the below into theDocument(s) field:

{
    "number": 1,
    "president": "George Washington",
    "birth_year": 1732,
    "death_year": 1799,
    "took_office": "1789-04-30",
    "left_office": "1797-03-04",
    "party": "No Party"
}

Click Submit document to add the document to the index. After a few moments, you will see the following:

Output after adding Document
Status: success
Response:
{
  "responseHeader": {
    "status": 0,
    "QTime": 509
  }
}

You can add more documents, with a similar or a completely different structure, but you can also continue with just one document.

Now, select Query on the left to query the document we just added. With the default values in this screen, after clicking on Execute Query, you will see 10 documents at most, depending on how many you added:

Query output
{
  "responseHeader": {
    "status": 0,
    "QTime": 58,
    "params": {
      "q": "*:*",
      "indent": "true",
      "wt": "json",
      "_": "1436827539345"
    }
  },
  "response": {
    "numFound": 1,
    "start": 0,
    "docs": [
      {
        "number": [
          1
        ],
        "president": [
          "George Washington"
        ],
        "birth_year": [
          1732
        ],
        "death_year": [
          1799
        ],
        "took_office": [
          "1789-04-30T00:00:00Z"
        ],
        "left_office": [
          "1797-03-04T00:00:00Z"
        ],
        "party": [
          "No Party"
        ],
        "id": "1ce12ed2-add9-4c65-aeb4-a3c6efb1c5d1",
        "_version_": 1506622425947701200
      }
    ]
  }
}

Conclusion

There are many more options available, but you have now successfully installed Solr and can start using it for your own site.

 
Leave a comment

Posted by on July 21, 2015 in Application Server, Solr

 

Compile Google Volley to JAR on Windows

By Sochinda,

Requirement:

1-Install Git
Go to: https://git-scm.com/download/win
and install

3-JDK
PATH: C:\Program Files\Java\jdk1.7.0_75\bin
JAVA_HOME: C:\Program Files\Java\jdk1.7.0_75

3-Android Command
Open Android Studio
File -> Project Stucture -> check SDK location
– add …\tools;…\platform-tools in PATH
4-Apache Ant
Go to: https://ant.apache.org/bindownload.cgi -> and click download file zip
Extract and copy to path as C:\apache-ant-1.9.6 (Example)
And Add to the last
PATH: C:\apache-ant-1.9.6\bin;

Step:
Open command prompt and type the bellow command:

$ git clone https://android.googlesource.com/platform/frameworks/volley
$ cd volley
$ android update project -p .
$ ant jar

 
Leave a comment

Posted by on July 10, 2015 in Android, Mobile Development