Code Monkey home page Code Monkey logo

pl-solr's Introduction

PL/Solr

PL/Solr is an prototypical PL/SQL interface for Apache Solr.

Installation

  1. Execute sql script sql/dba_create_user_and_grants.sql as SYSDBA. Schema PLSOLR and necessary roles and acl's will be created.

  2. Execute script sql/install.sql as user PLSOLR. PL/SQL packages and user defined types will be created.

  3. Setup an external Apache Solr instance.

  4. Replace default Apache Solr configuration with provided configuration from solr/*

  5. Put ojdbc6.jar in Apache Solr's classpath

####Query Solr with sql:####

 SELECT
   *
 FROM
   TABLE(
     SOLR_PKG.EXTRACT_RESULTS(
       RESULTSET => SOLR_PKG.SEARCH(
                      QUERY_CLAUSE => SOLR_PKG.BUILD_QUERY('h*'),
                      FILTER_CLAUSE => SOLR_PKG.BUILD_FILTER('artikel_packeinheit','10'),
                      FACET_CLAUSE => SOLR_PKG.BUILD_FACET('artikel_hersteller')
                    )
       )
   )

####Search result with facet:####

 SELECT
   *
 FROM
   TABLE(
     SOLR_PKG.EXTRACT_FACET(
       RESULTSET => SOLR_PKG.SEARCH(
                      QUERY_CLAUSE => SOLR_PKG.BUILD_QUERY('h*'),
                      FILTER_CLAUSE => SOLR_PKG.BUILD_FILTER('artikel_packeinheit','10'),
                      FACET_CLAUSE => SOLR_PKG.BUILD_FACET('artikel_hersteller')
                    ),
       FACET_FIELD => 'artikel_hersteller'
     )
   )

####Work with raw Solr xml response in PL/SQL blocks:####

 DELCARE
   XML_DOC XMLTYPE;
 BEGIN
   XML_DOC := SOLR_PKG.SEARCH(
                QUERY_CLAUSE => SOLR_PKG.BUILD_QUERY('h*'),
                FILTER_CLAUSE => SOLR_PKG.BUILD_FILTER('artikel_packeinheit','10'),
                FACET_CLAUSE => SOLR_PKG.BUILD_FACET('artikel_hersteller')
              )
 END;

####Run delta imports with Solr's Data Import Handler:####

 CREATE OR REPLACE TRIGGER ARTIKEL_TRG
   AFTER INSERT OR UPDATE OR DELETE ON ARTIKEL
 DECLARE
   STATUS VARCHAR2(10);
 BEGIN
   SELECT
     VALUE INTO STATUS
   FROM
     TABLE(SOLR_DATAIMPORT_PKG.STATUS)
       WHERE KEY = 'Status';
   IF STATUS = SOLR_DATAIMPORT_PKG.IDLE THEN
     SOLR_DATAIMPORT_PKG.DELTA_IMPORT;
   END IF;
 END ARTIKEL_TRG

####Retrieve status of Solr's Data Import Handler:####

 SELECT * FROM TABLE(SOLR_DATAIMPORT_PKG.STATUS);
 
 KEY                               VALUE
 --------------------------------- -----------------------------
 Status                            busy
 Command                           status
 Import Response                   A command is still running...
 Time Elapsed                      0:0:6.250
 Total Requests made to DataSource 1
 Total Rows Fetched                77000
 Total Documents Processed         77000
 Total Documents Skipped           0
 Full Dump Started                 2011-07-09 03:43:41

pl-solr's People

Stargazers

Alexander Kardapolov avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.