indexer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2016 License: MIT Imports: 14 Imported by: 3

Documentation

Index

Constants

View Source
const POST_TAG = "\u0001"
View Source
const PRE_TAG = "\u0001"

Variables

View Source
var BLEVE_HIT_TAG = regexp.MustCompile(`<mark>(.*?)</mark>`)
View Source
var CRLF_PATTERN = regexp.MustCompile(`\r?\n|\r`)
View Source
var ES_HIT_TAG = regexp.MustCompile(`\x{0001}(.*?)\x{0001}`)
View Source
var MAPPING = []byte(`{
	"types": {
		"file": {
			"enabled": true,
			"dynamic": true,
			"properties": {
				"blob": {
					"enabled": true,
					"dynamic": true,
					"fields": [{
						"type": "text",
						"analyzer": "en",
						"store": true,
						"index": true,
						"include_term_vectors": true,
						"include_in_all": false
					}],
					"default_analyzer": ""
				},
				"content": {
					"enabled": true,
					"dynamic": true,
					"fields": [{
						"type": "text",
						"analyzer": "en",
						"store": true,
						"index": true,
						"include_term_vectors": true,
						"include_in_all": true
					}],
					"default_analyzer": ""
				},
				"metadata": {
					"enabled": true,
					"dynamic": true,
					"properties": {
						"organization": {
							"enabled": true,
							"dynamic": true,
							"fields": [{
								"type": "text",
								"analyzer": "en",
								"store": true,
								"index": true,
								"include_term_vectors": true,
								"include_in_all": false
							}],
							"default_analyzer": ""
						},
						"project": {
							"enabled": true,
							"dynamic": true,
							"fields": [{
								"type": "text",
								"analyzer": "en",
								"store": true,
								"index": true,
								"include_term_vectors": true,
								"include_in_all": false
							}],
							"default_analyzer": ""
						},
						"repository": {
							"enabled": true,
							"dynamic": true,
							"fields": [{
								"type": "text",
								"analyzer": "en",
								"store": true,
								"index": true,
								"include_term_vectors": true,
								"include_in_all": false
							}],
							"default_analyzer": ""
						},
						"refs": {
							"enabled": true,
							"dynamic": true,
							"fields": [{
								"type": "text",
								"analyzer": "en",
								"store": true,
								"index": true,
								"include_term_vectors": true,
								"include_in_all": false
							}],
							"default_analyzer": ""
						},
						"path": {
							"enabled": true,
							"dynamic": true,
							"fields": [{
								"type": "text",
								"analyzer": "en",
								"store": true,
								"index": true,
								"include_term_vectors": true,
								"include_in_all": false
							}],
							"default_analyzer": ""
						},
						"ext": {
							"enabled": true,
							"dynamic": true,
							"fields": [{
								"type": "text",
								"analyzer": "en",
								"store": true,
								"index": true,
								"include_term_vectors": true,
								"include_in_all": false
							}],
							"default_analyzer": ""
						}
					},
					"default_analyzer": ""
				}
			},
			"default_analyzer": ""
		}
	},
	"default_mapping": {
		"enabled": true,
		"dynamic": true,
		"default_analyzer": ""
	},
	"type_field": "_type",
	"default_type": "file",
	"default_analyzer": "standard",
	"default_datetime_parser": "dateTimeOptional",
	"default_field": "_all",
	"store_dynamic": true,
	"index_dynamic": true,
	"analysis": {}
}`)

Functions

This section is empty.

Types

type BatchMethod

type BatchMethod int
const (
	ADD BatchMethod = iota
	DELETE
)

type BleveIndexer

type BleveIndexer struct {
	// contains filtered or unexported fields
}

func (*BleveIndexer) BatchFileIndex

func (b *BleveIndexer) BatchFileIndex(requestBatch []FileIndexOperation) error

func (*BleveIndexer) CreateFileIndex

func (b *BleveIndexer) CreateFileIndex(requestFileIndex FileIndex) error

func (*BleveIndexer) DeleteIndexByRefs

func (b *BleveIndexer) DeleteIndexByRefs(organization string, project string, repository string, refs []string) error

func (*BleveIndexer) SearchQuery

func (b *BleveIndexer) SearchQuery(query string) SearchResult

func (*BleveIndexer) UpsertFileIndex

func (b *BleveIndexer) UpsertFileIndex(requestFileIndex FileIndex) error

type ESIndexer

type ESIndexer struct {
	// contains filtered or unexported fields
}

func (*ESIndexer) BatchFileIndex

func (e *ESIndexer) BatchFileIndex(requestBatch []FileIndexOperation) error

func (*ESIndexer) CreateFileIndex

func (e *ESIndexer) CreateFileIndex(requestFileIndex FileIndex) error

func (*ESIndexer) DeleteIndexByRefs

func (e *ESIndexer) DeleteIndexByRefs(organization string, project string, repository string, refs []string) error

func (*ESIndexer) Init

func (esi *ESIndexer) Init()

func (*ESIndexer) SearchQuery

func (e *ESIndexer) SearchQuery(query string) SearchResult

func (*ESIndexer) UpsertFileIndex

func (e *ESIndexer) UpsertFileIndex(requestFileIndex FileIndex) error

type FileIndex

type FileIndex struct {
	Blob     string   `json:"blob"`
	Metadata Metadata `json:"metadata"`
	Content  string   `json:"content"`
}

func NewFileIndex

func NewFileIndex(blob string, organization string, project string, repo string, ref string, path string, content string) FileIndex

type FileIndexOperation

type FileIndexOperation struct {
	Method    BatchMethod
	FileIndex FileIndex
}

type HighlightSource

type HighlightSource struct {
	Offset  int    `json:"offset"`
	Content string `json:"content"`
}

type Hit

type Hit struct {
	Source Source `json:"_source"`
	// Highlight map[string][]string `json:"highlight"`
	Preview []util.TextPreview `json:"preview"`
}

type Indexer

type Indexer interface {
	CreateFileIndex(requestFileIndex FileIndex) error
	UpsertFileIndex(requestFileIndex FileIndex) error
	BatchFileIndex(operations []FileIndexOperation) error
	DeleteIndexByRefs(organization string, project string, repository string, refs []string) error

	SearchQuery(query string) SearchResult
}

func NewBleveIndexer

func NewBleveIndexer(config config.Config, reader *repo.GitRepoReader) Indexer

func NewESIndexer

func NewESIndexer(config config.Config, reader *repo.GitRepoReader) Indexer

type Metadata

type Metadata struct {
	Organization string   `json:"organization"`
	Project      string   `json:"project"`
	Repository   string   `json:"repository"`
	Refs         []string `json:"refs"`
	Path         string   `json:"path"`
	Ext          string   `json:"ext"`
}

type SearchResult

type SearchResult struct {
	Time  float64 `json:"time"`
	Size  int64   `json:"size"`
	Limit int     `json:"limit"`

	Current int   `json:"current"`
	Next    int   `json:"next"`
	Hits    []Hit `json:"hits"`
	// contains filtered or unexported fields
}

type Source

type Source struct {
	Blob     string   `json:"blob"`
	Metadata Metadata `json:"metadata"`
}

Jump to

Keyboard shortcuts

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