Solr Installation And Configuration

1.  Solr Installation And Configuration.
     2.    Jboss 4.x  Installation
     3.    Mysql 5.X   Installation/Configuration
     4.    Build Project on Eclipse
     5.    Solr Conf.  With Jboss 4.x
     6.    Run SolrJ Example…

1.    Solr3.4  Installation.
We will of course need a Solr installation so head on over to the mirror download location at   http://www.apache.org/dyn/closer.cgi/lucene/solr/  and click on a mirror that is closest to you
1.  Unzip or untar the downloaded solr nightly build package. Assume the unzipped directory is solr.
2. Cd into solr/example directory which has a standalone solr server running on Jetty. But we can run solr on Jboss/Tomcat Server also.
3.  If you want execute use default Jetty server Execute Bellow the command.
E:\apache-solr-3.4.0\example>java -jar start.jar (For Default xml file data access)
4.  If you want execute use default jetty server with HSQL database Execute Bellow the command.
     E:\apache-solr-3.4.0\example>java -Dsolr.solr.home="./example-DIH/solr/" -jar start.jar  (For Default Hsql database access)

Configuration: Open up the /solr/example\solr/conf/schema.xml file in your favorite editor .We will be creating the configuration from scratch. At some point in time, it would be informative to read through the comments in the file to get a feel of what is going on, at this point we will go through each line in gruesome detail.
Now that you have a blank file to play with, the schema is broken into three parts:
1.   Field Types,
2.   Fields, and
3.   Configuration

Explanation schema.xml File

The following lines is the simplest configuration that I could come up with, we will go through it line by line.

1. The xml declaration:
       
2. The start of the schema element, note that the name attribute is only used for display purposes and can be anything you wish - we will leave it as "example" for the moment - we will see how this name is displayed in the administration console later.
      
3. The start of the field type definitions
   
4. The type definition of a string type
    
             sortMissingLast="true" omitNorms="true"/>
5. The end of the field type definitions
   
8. The start of the fields definitions, each field that is to be used in Solr must have a corresponding definition within this element.
9. The definition of the id field as a string - note how the type attribute's value of string matches the field type definition in line 04.
 
10. The definition of the category field as a string

11. The definition of the size field as a string
12. The definition of the text field as a string - Note that this is a special field used as a catch-all field for searching the data. We will be using this pattern frequently throughout the tutorial.
13. The end of the fields definitions
14. The unique identifier for each of the documents that will be stored in the Solr index.
id

15. The default field to search against - the chosen field text was defined as a special 'catch-all' field and will be referenced in the element text
16. Defines the default operator which may be either AND or OR. We are using AND as the default operator for reasons that we will go into later.
17. The copyField element (as the name would suggest) copies the information from one field to another. The text field is used so that any data that we wish to search on is indexed within this field. This saves us the hassle of querying three separate fields (i.e. the 'id', 'category' and 'size' fields) when looking for a keyword match.
18. The end of the schema element.


2.    Jboss Installation.
You can Click on Bellow the Link installed the jboss..
3.   Mysql5.X Database.
You can also need the downloaded the latest Mysql JDBC driver.
Copy theis sownloaded mysql jdbc driver  file into jboss lib or solr/lib directory.
Create a new xml file into data folder “db-data-config.xml”  and create database connection with solr query.

<dataConfig>
   
      <dataSource   driver="com.mysql.jdbc.Driver"
                    url="jdbc:mysql://localhost:3306/atg_trn"
                    user="root"
                    password="root"/>

    <document>
     <entity name="item" query="select * from item"
         deltaQuery="select id from item where last_modified > '${dataimporter.last_index_time}'">
            <field column="NAME" name="name" />
            <field column="NAME" name="nameSort" />
            <field column="NAME" name="alphaNameSort" />
            <entity name="feature" 
        query="select DESCRIPTION from FEATURE where ITEM_ID='${item.ID}'"
  deltaQuery="select ITEM_ID from FEATURE where last_modified > '${dataimporter.last_index_time}'"
        parentDeltaQuery="select ID from item where ID=${feature.ITEM_ID}">
      <field name="features" column="DESCRIPTION" />
    </entity>
           <entity name="item_category"
query="select CATEGORY_ID from item_category where ITEM_ID='${item.ID}'"
deltaQuery="select ITEM_ID, CATEGORY_ID from item_category where last_modified > '${dataimporter.last_index_time}'"
parentDeltaQuery="select ID from item where ID=${item_category.ITEM_ID}">
           <entity name="category"
query="select DESCRIPTION from category where ID = '${item_category.CATEGORY_ID}'"
deltaQuery="select ID from category where last_modified >   '${dataimporter.last_index_time}'"
parentDeltaQuery="select ITEM_ID, CATEGORY_ID from item_category where CATEGORY_ID=${category.ID}">
            <field column="description" name="cat" />
           </entity>
          </entity>
        </entity>
    </document>
</dataConfig>

Add Bellow the Code in Solrconf.xml file

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

Then Execute the Jboss :- show bellow the link on browser…