GithubHelp home page GithubHelp logo

isabella232 / research-17 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from redislabs/research

0.0 0.0 0.0 110 KB

Redis search and indexing in Java

License: GNU Affero General Public License v3.0

Java 99.30% Lua 0.70%

research-17's Introduction

ReSearch - Redis Scalable Search Engine

Overview

Research is a library wrapping Redis with advanced search capabilities, automating indexing and retrieval.

Main Features include:

  • Fast Auto-suggestion using lexical ranges.
  • Multi-facet filters, including ranges and geo-filtering.
  • Designed to scale: Indexes are partitioned across multiple redis instances, a design which allows scaling across large document sets and multi-machine clusters with ease.
  • Simple API with a structured query builder.

TL;DR - API Usage Example

Here's what you need to get things going fast:

import com.redislabs.research.*;
import com.redislabs.research.redis.*;

Create an index spec:

// Create an index spec, telling ReSearch how to index documents:
// this spec tells the engine to create a prefix based index for a property named "title",
// indexing word-suffixes of it for completion as well 
Spec spec = new Spec(Spec.prefix("title", true));

Create indexes and a document store

// Create a PartitionedIndex which partitions indexes across multiple cluster nodes

// the number of internal partitions the index has. This should be higher than the number of
// cluster shards you have.
int numPartitions = 8;
// distributed query timeout
int timeoutMS = 500;
// redis hosts to connect to
String[] redisHosts = new String[] {"redis://localhost:6379", "redis://localhost:6380", ... };

Index idx = new PartitionedIndex("myIndex", //index name
        spec, 
        numPartitions, 
        timeout,
        redisHosts);


// Create a document store. The index only retrieves document ids. 
// The store actually holds the documents. This is optional if you want to implement a store yourself
// JSONStore just stores documents as JSON blobs in redis
DocumentStore st = new JSONStore("redis://localhost:6379");

Index some documents

Document[] docs = {
        new Document("doc1").set("title", "Redis in action")
            .set("description", "A book about redis in action"),
            
        new Document("doc2").set("title", "Redis in traction")
            .set("description", "A book about redis in traction")
};            

idx.index(docs); // this call accepts multiple documents and indexes them as a single transaction

st.store(docs); //save the documents in the store

5. query the index

// Build a query
Query query = new Query("myIndex").filterPrefix("title", "redis");

// load the ids
List<String> ids = idx.get(query);

// load the documents
List<Document> docs = st.get(ids);

Defining Indexes

Creating Documents

Retrieving Documents

Design

Index Design

research-17's People

Contributors

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