GithubHelp home page GithubHelp logo

solrmongoimporter's Introduction

Solr Mongo Importer

Welcome to the Solr Mongo Importer project. This project provides MongoDb support for the Solr Data Import Handler.

I rewrited most code to suit my project's needs, but I think it is also suitable to most cases if you want to index a MongoDB with Solr.

Features

  • Retrive data from a MongoDb collection
  • Authenticate using MongoDb authentication
  • Map Mongo fields to Solr fields
  • Delta Import - NOTE: It is all based on your schema design

Classes

  • MongoDataSource - Provides a MongoDb datasource
    • database (required) - The name of the database you want to connect to
    • host (optional - default: localhost)
    • port (optional - default: 27017)
    • username (optional)
    • password (optional)
  • MongoEntityProcessor - Use with the MongoDataSource to query a MongoDb collection
    • collection (required)
    • query (required)
  • MongoMapperTransformer - Map MongoDb fields to your Solr schema
    • column (required) - Solr uses this as field name
    • jsonpath (required) - See Jayway JsonPath, and result should return List

Installation

  1. Firstly you will need a copy of the Solr Mongo Importer jar.
    1. Build your own using the ant build script you will need the JDK installed as well as Ant and Ivy
  2. You will also need the Mongo Java driver JAR and Jayway JsonPath
  3. Place both of these jars in your Solr core lib folder (If you created a core with name 'MyCore', place 'lib' under folder 'MyCore', i.e. 'MyCore/lib')

##Usage Here is an example showing the use of all components:

MongoDB Collection: Inventory.data

{
    "_id": ObjectId("56a5831083180eb506dafdcf"),
    "CompanyData": {
        "name": "My Company"
    },
    "ProductData": [
        {
            "title": "My Title 1",
            "description": "Long Description 1"
        },
        {
            "title": "My Title 2",
            "description": "Long Description 2"
        }
    ]
}

data-config.xml

<?xml version="1.0" encoding="UTF-8" ?>
<dataConfig>
    <dataSource name="MyMongo" type="MongoDataSource" database="Inventory" />
    <document name="Products">
        <entity processor="MongoEntityProcessor"
                query="{'CompanyData.name':'My Company'}"
                collection="data"
                datasource="MyMongo"
                transformer="MongoMapperTransformer">
            <field column="title" jsonpath="$.ProductData[*].title" />
            <field column="description" jsonpath="$.ProductData[*].description" />
        </entity>
    </document>
</dataConfig>

Solr

{
    "_id": "56a5831083180eb506dafdcf",
    "title": [
        "My Title 1",
        "My Title 2"
    ],
    "description": [
        "Long Description 1",
        "Long Description 2"
    ]
}

solrmongoimporter's People

Contributors

braskinfvr avatar yitomok avatar

Stargazers

 avatar

Watchers

 avatar  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.