All Projects → shijiebei2009 → RedisDirectory

shijiebei2009 / RedisDirectory

Licence: Apache-2.0 license
🔒 A simple redis storage engine for lucene - 基于Redis的Lucene索引存储引擎 - Star me if you like it!

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to RedisDirectory

Puck Core
Open source, cross platform .NET Core CMS. Fast, scalable, code-first, unobtrusive and extensible with powerful querying and Lucene integration.
Stars: ✭ 115 (+538.89%)
Mutual labels:  lucene
Code4java
Repository for my java projects.
Stars: ✭ 164 (+811.11%)
Mutual labels:  lucene
Lucene
lucene技术细节
Stars: ✭ 233 (+1194.44%)
Mutual labels:  lucene
Elassandra
Elassandra = Elasticsearch + Apache Cassandra
Stars: ✭ 1,610 (+8844.44%)
Mutual labels:  lucene
Everywhere
🔧 A tool can really search everywhere for you.
Stars: ✭ 147 (+716.67%)
Mutual labels:  lucene
Roaringbitmap
A better compressed bitset in Java
Stars: ✭ 2,460 (+13566.67%)
Mutual labels:  lucene
Ik Analyzer
支持Lucene5/6/7/8+版本, 长期维护。
Stars: ✭ 112 (+522.22%)
Mutual labels:  lucene
cloud-note
无道云笔记,原生JSP的仿有道云笔记项目
Stars: ✭ 66 (+266.67%)
Mutual labels:  lucene
Fxdesktopsearch
A JavaFX based desktop search application.
Stars: ✭ 147 (+716.67%)
Mutual labels:  lucene
Examine
A .NET indexing and search engine powered by Lucene.Net
Stars: ✭ 208 (+1055.56%)
Mutual labels:  lucene
Querqy
Query preprocessor for Java-based search engines (Querqy Core and Solr implementation)
Stars: ✭ 122 (+577.78%)
Mutual labels:  lucene
Elastiknn
Elasticsearch plugin for nearest neighbor search. Store vectors and run similarity search using exact and approximate algorithms.
Stars: ✭ 139 (+672.22%)
Mutual labels:  lucene
Smartstorenet
Open Source ASP.NET MVC Enterprise eCommerce Shopping Cart Solution
Stars: ✭ 2,363 (+13027.78%)
Mutual labels:  lucene
Luqum
A lucene query parser generating ElasticSearch queries and more !
Stars: ✭ 118 (+555.56%)
Mutual labels:  lucene
Clavin
CLAVIN (Cartographic Location And Vicinity INdexer) is an open source software package for document geoparsing and georesolution that employs context-based geographic entity resolution.
Stars: ✭ 237 (+1216.67%)
Mutual labels:  lucene
Spark Lucenerdd
Spark RDD with Lucene's query and entity linkage capabilities
Stars: ✭ 114 (+533.33%)
Mutual labels:  lucene
Eclipse Instasearch
Eclipse plug-in for fast code search
Stars: ✭ 165 (+816.67%)
Mutual labels:  lucene
lucene-demo
基于lucene-5.5.4实现的全文检索demo
Stars: ✭ 70 (+288.89%)
Mutual labels:  lucene
hermes
A library and microservice implementing the health and care terminology SNOMED CT with support for cross-maps, inference, fast full-text search, autocompletion, compositional grammar and the expression constraint language.
Stars: ✭ 131 (+627.78%)
Mutual labels:  lucene
Jblog
🔱一个简洁漂亮的java blog 👉基于Spring /MVC+ Hibernate + MySQL + Bootstrap + freemarker. 实现 🌈
Stars: ✭ 187 (+938.89%)
Mutual labels:  lucene

RedisDirectory Build Status License

A simple redis storage engine for lucene

The repo is just a very simple implements for store lucene's index files in redis. I initially did this project is aims to be usable in production. It's a complete concise implementation, you can use a different jedis implements (Jedis/Jedis Pool/Sharded Jedis Pool/Jedis Cluster) without modifying the code. It supports index file slice, compress index file contents, mutex lock and redis file cache. With redis file cache it can help you improve the performance of writing index files. In this repo the lock implements by java nio file lock, it can release lock when jvm exit abnormal. If you use a singleton lock, then you can not achieve mutual exclusion across multi processes, or else if you use redis to store a flag as lock, then the flag will still store in redis when the java virtual machine exit abnormal. And when you use next time, you can not obtain lock again unless you delete the lock flag in the redis manual.

Requirements

  • JDK 1.8+
  • Lucene 5.5.0+
  • Jedis 2.9.0+
  • Lombok 1.16.12+
  • Log4j 2.6.2+
  • Guava 20.0+
  • Snappy-java 1.1.2.6+

Installation

  • Clone the repo git clone [email protected]:shijiebei2009/RedisDirectory.git RedisDirectory
  • cd RedisDirectory
  • use maven commands or gradle commands to build the project

Features

  • Supports pool
  • Supports sharding
  • Supports cluster (not tested)
  • Supports Maven or Gradle Compile
  • Supports storage level distribution

Usage

Make sure you have the RedisDirectory.jar in you class path (Gradle or Maven can help you). To use it just like follows, you can set stop-writes-on-bgsave-error no in the redis.windows.conf if it occurs MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.

JedisPool

IndexWriterConfig indexWriterConfig = new IndexWriterConfig(new WhitespaceAnalyzer()).setOpenMode(IndexWriterConfig
                .OpenMode.CREATE);
JedisPool jedisPool = new JedisPool(new JedisPoolConfig(), "localhost", 6379);
RedisDirectory redisDirectory = new RedisDirectory(new JedisPoolStream(jedisPool));
IndexWriter indexWriter = new IndexWriter(redisDirectory, indexWriterConfig);
indexWriter.addDocument(...);
indexWriter.close();
redisDirectory.close();

Jedis

IndexWriterConfig indexWriterConfig = new IndexWriterConfig(new WhitespaceAnalyzer()).setOpenMode(IndexWriterConfig
                .OpenMode.CREATE);
RedisDirectory redisDirectory = new RedisDirectory(new JedisStream("localhost", 6379));
IndexWriter indexWriter = new IndexWriter(redisDirectory, indexWriterConfig);
indexWriter.addDocument(...);
indexWriter.close();
redisDirectory.close();

ShardedJedisPool

IndexWriterConfig indexWriterConfig = new IndexWriterConfig(new WhitespaceAnalyzer()).setOpenMode(IndexWriterConfig
                .OpenMode.CREATE);
List<JedisShardInfo> shards = new ArrayList<>();
JedisShardInfo si = new JedisShardInfo("localhost", 6379);
shards.add(si);
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
ShardedJedisPool shardedJedisPool = new ShardedJedisPool(jedisPoolConfig, shards);
RedisDirectory redisDirectory = new RedisDirectory(new ShardedJedisPoolStream(shardedJedisPool));
IndexWriter indexWriter = new IndexWriter(redisDirectory, indexWriterConfig);
indexWriter.addDocument(...);
indexWriter.close();
redisDirectory.close();

File is divided into blocks and stored as HASH in redis in binary format that can be loaded on demand. You can customise the block size by modifying the DEFAULT_BUFFER_SIZE in config file. Remember its a 1 time intialization once index is created on a particular size it can't be changed; higher block size causes lower fragmentation.

The index files will store in redis as follows:
directory metadata (user definition) => index file name => index file length
file metadata (user definition) => @index file name:block number => the block values

TODO

I've just started. Have to:

  • Include support for Snappy compression to compress file block.
  • Rock solid JUNIT test cases for each class.
  • Enable atomic operations on RedisFile, this will allow multiple connections to manipulate single file.
  • Redundancy support, maintain multiple copies of a file (or its blocks).

Simple Performance Test ( Windows 7, i7 4790CPU, 8GB, Redis-x64-3.2 )

On my computer with windows redis downloaded from here developed by MSOpenTech. In command line, I run RedisDirectory jar file with arguments like this java -Xms1024m -Xmx5120m -jar RedisDirectory-0.0.1.jar, and the performance test results are as below. When the redis as the store engine, before the program start I will run flushall in redis and after the program done, I get the index size by info in redis commands line.

Type Documents Fields Write Time Search Time(10 million) Index Size
RamDirectory 10 million 15 303s 278s 2.63G(Approximately)
MMapDirectory 10 million 15 381s 307s 2.59G
RedisDirectory (JedisPool) 10 million 15 423s 632s used_memory_human:2.67G
RedisDirectory (Jedis) 10 million 15 452s 536s used_memory_human:2.67G
RedisDirectory (ShardedJedisPool) 10 million 15 477s 790s used_memory_human:2.67G

The above test did not compress the index file. You can customise the compress index file or not by modifying COMPRESS_FILE=false in config file. Under normal circumstances, in the local machine test, compressed file performance is not as good as uncompressed file performance. In the 10 million of documents test, the compression index file consumes write time about 680s.

RedisDirectory Architecture

RedisDirectory Architecture

Related Project

License

Copyright 2016 Xu Wang

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].