Skip to content

sucode/solrMongoDBImporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Solr MongoDB Importer

Thi is a MongoDB Data Importer for Solr.

Features

  • import data from MongoDB to solr
  • support full import and delta import
  • support for transform from MongoDB's ObjectID to Long

Dependencies

  • mongo-java-driver

Usage

DataSource config

  • support config items
    1. host (default: localhost)
    2. port (default: 27017)
    3. database
    4. username (optional)
    5. password (optional)
<dataConfig>
	<dataSource name="mongod" type="MongoDataSource" host="127.0.0.1" port="27017" database="example" />
</dataConfig>

Entity config

  • support config items
    1. collection
    2. command
    3. deltaCommand (optional, if not set, and request a delta import, we will use command instead)
<entity processor="MongoDBEntityProcessor" dataSource="mongod" name="test" collection="coll" command="{}">
	<field column="_id" name="docId"/>
	<field column="title" name="title"/>
	<!-- other fileds -->
</entity>

ObjectId transformer

Somethime we need a Long docId, but we have ObjectId in MongoDB, so a transformer may help.

This transfomer just cover the ObjectId to it's hashcode :-)

<entity processor="MongoDBEntityProcessor" dataSource="mongod" name="test" collection="coll" command="{}">
	<field column="_id" name="docId" hashObjectId="true"/> <!-- docId has long type-->
	<field column="title" name="title"/>
	<!-- other fileds -->
</entity>

Put it together

<dataConfig>
	<dataSource name="mongod" type="MongoDataSource" host="127.0.0.1" port="27017" database="example" />
	<entity processor="MongoDBEntityProcessor" dataSource="mongod" name="test" collection="coll" command="{}">
		<field column="_id" name="docId" hashObjectId="true"/> <!-- docId has long type-->
		<field column="title" name="title"/>
		<!-- other fileds -->
	</entity>
</dataConfig>

About

A MongoDB Data Importer for solr

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages