gosearchengine

package module
v0.0.0-...-531e283 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2017 License: MIT Imports: 4 Imported by: 0

README

Go Search Engine

Build Status Go Report Card BCH compliance GoDoc

This project is intended for educational purposes.

Usage

Creating an index
index := NewIndex(
  Mapping{
    Attributes: map[string]analyzers.Analyzer{
      "body": analyzers.NewSimpleAnalyzer(),
    },
  },
)
Indexing
docA := core.Document{
  Attributes: map[string]string{
    "body": "The quick brown fox jumps over the lazy dog",
  },
}

index.Index(docA)
Querying
searchResult := index.Search("body", "quick fox")

Credits

Project inspired by the presentation "Building A Python-Based Search Engine" on Pycon US 2012 by Daniel Lindsley.

Documentation

Overview

Package gosearchengine implements a search engine

It consists of several structures to implement indexing and search of documents.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

type Index struct {
	InvertedIndexes map[string]*indexing.InvertedIndex
	DocumentStore   *indexing.DocumentStore
	Mapping         Mapping
}

Index values control the index structures.

func NewIndex

func NewIndex(mapping Mapping) *Index

NewIndex initializes an InvertedIndex with the given Mapping.

func (*Index) Index

func (i *Index) Index(document core.Document)

Index stores and indexes a document in the index.

func (*Index) Search

func (i *Index) Search(attribute string, query string) []core.Document

Search queries the index for documents satisfying the given query.

type Mapping

type Mapping struct {
	Attributes map[string]analyzers.Analyzer
}

Mapping values control analyzers of each document field

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL