indexer

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2017 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const NO_EXT = "/noext/"
View Source
const POST_TAG = "\u0001"
View Source
const PRE_TAG = "\u0001"

Variables

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": "keyword",
						"store": true,
						"index": true,
						"include_term_vectors": true,
						"include_in_all": false
					}],
					"default_analyzer": ""
				},
				"fullRefs": {
					"enabled": true,
					"dynamic": true,
					"fields": [{
						"type": "text",
						"analyzer": "full_ref",
						"store": true,
						"index": true,
						"include_term_vectors": true,
						"include_in_all": false
					}],
					"default_analyzer": ""
				},
				"organization": {
					"enabled": true,
					"dynamic": true,
					"fields": [{
						"type": "text",
						"analyzer": "keyword",
						"store": true,
						"index": true,
						"include_term_vectors": false,
						"include_in_all": false
					}],
					"default_analyzer": ""
				},
				"project": {
					"enabled": true,
					"dynamic": true,
					"fields": [{
						"type": "text",
						"analyzer": "keyword",
						"store": true,
						"index": true,
						"include_term_vectors": false,
						"include_in_all": false
					}],
					"default_analyzer": ""
				},
				"repository": {
					"enabled": true,
					"dynamic": true,
					"fields": [{
						"type": "text",
						"analyzer": "keyword",
						"store": true,
						"index": true,
						"include_term_vectors": false,
						"include_in_all": false
					}],
					"default_analyzer": ""
				},
				"branches": {
					"enabled": true,
					"dynamic": true,
					"fields": [{
						"type": "text",
						"analyzer": "keyword",
						"store": true,
						"index": true,
						"include_term_vectors": false,
						"include_in_all": false
					}],
					"default_analyzer": ""
				},
				"tags": {
					"enabled": true,
					"dynamic": true,
					"fields": [{
						"type": "text",
						"analyzer": "keyword",
						"store": true,
						"index": true,
						"include_term_vectors": false,
						"include_in_all": false
					}],
					"default_analyzer": ""
				},
				"path": {
					"enabled": true,
					"dynamic": true,
					"fields": [{
						"type": "text",
						"analyzer": "path_hierarchy",
						"store": true,
						"index": true,
						"include_term_vectors": true,
						"include_in_all": false
					}],
					"default_analyzer": ""
				},
				"ext": {
					"enabled": true,
					"dynamic": true,
					"fields": [{
						"type": "text",
						"analyzer": "keyword",
						"store": true,
						"index": true,
						"include_term_vectors": true,
						"include_in_all": false
					}],
					"default_analyzer": ""
				},
				"encoding": {
					"enabled": true,
					"dynamic": true,
					"fields": [{
						"type": "text",
						"analyzer": "keyword",
						"store": true,
						"index": true,
						"include_term_vectors": true,
						"include_in_all": false
					}],
					"default_analyzer": ""
				},
				"size": {
					"enabled": true,
					"dynamic": true,
					"fields": [{
						"type": "number",
						"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": false,
						"index": true,
						"include_term_vectors": true,
						"include_in_all": true
					}],
					"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

func FullRefAnalyzer added in v0.2.0

func FullRefAnalyzer(config map[string]interface{}, cache *registry.Cache) (*analysis.Analyzer, error)

func FullRefTokenizerConstructor added in v0.2.0

func FullRefTokenizerConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.Tokenizer, error)

func GetExt added in v0.2.0

func GetExt(p string) string

func PathHierarchyAnalyzer added in v0.2.0

func PathHierarchyAnalyzer(config map[string]interface{}, cache *registry.Cache) (*analysis.Analyzer, error)

func PathHierarchyTokenizerConstructor added in v0.2.0

func PathHierarchyTokenizerConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.Tokenizer, error)

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) Count added in v0.4.0

func (b *BleveIndexer) Count() (uint64, error)

func (*BleveIndexer) CreateFileIndex

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

func (*BleveIndexer) DeleteIndexByRefs

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

func (*BleveIndexer) Exists added in v0.4.0

func (b *BleveIndexer) Exists(fileIndex FileIndex) (bool, error)

func (*BleveIndexer) SearchQuery

func (b *BleveIndexer) SearchQuery(query string, filterParams FilterParams, page int) (SearchResult, error)

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) Count added in v0.4.0

func (e *ESIndexer) Count() (uint64, error)

func (*ESIndexer) CreateFileIndex

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

func (*ESIndexer) DeleteIndexByRefs

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

func (*ESIndexer) Exists added in v0.4.0

func (e *ESIndexer) Exists(requestFileIndex FileIndex) (bool, error)

func (*ESIndexer) Init

func (esi *ESIndexer) Init()

func (*ESIndexer) SearchQuery

func (e *ESIndexer) SearchQuery(query string, filterParams FilterParams, page int) (SearchResult, error)

func (*ESIndexer) UpsertFileIndex

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

type FacetResult added in v0.2.0

type FacetResult struct {
	Field   string     `json:"field"`
	Total   int        `json:"total"`
	Missing int        `json:"missing"`
	Other   int        `json:"other"`
	Terms   TermFacets `json:"terms"`
}

type FacetResults added in v0.2.0

type FacetResults map[string]FacetResult

type FileIndex

type FileIndex struct {
	Metadata
	FullRefs []string `json:"fullRefs"`
	Content  string   `json:"content"`
}

func NewFileIndex

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

type FileIndexOperation

type FileIndexOperation struct {
	Method    BatchMethod
	FileIndex FileIndex
}

type FilterParams added in v0.2.0

type FilterParams struct {
	Exts          []string `json:"x,omitempty"`
	Organizations []string `json:"o,omitempty"`
	Projects      []string `json:"p,omitempty"`
	Repositories  []string `json:"r,omitempty"`
	Branches      []string `json:"b,omitempty"`
	Tags          []string `json:"t,omitempty"`
}

type FullRefTokenizer added in v0.2.0

type FullRefTokenizer struct {
}

func (*FullRefTokenizer) Tokenize added in v0.2.0

func (t *FullRefTokenizer) Tokenize(input []byte) analysis.TokenStream

type HighlightSource

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

type Hit

type Hit struct {
	Metadata
	Keyword []string `json:"keyword"`
	// 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, branches []string, tags []string) error

	Count() (uint64, error)
	SearchQuery(query string, filters FilterParams, page int) (SearchResult, error)

	Exists(requestFileIndex FileIndex) (bool, error)
}

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 {
	Blob         string   `json:"blob"`
	Organization string   `json:"organization"`
	Project      string   `json:"project"`
	Repository   string   `json:"repository"`
	Branches     []string `json:"branches"`
	Tags         []string `json:"tags"`
	Path         string   `json:"path"`
	Ext          string   `json:"ext"`
	Size         int64    `json:"size"`
	Encoding     string   `json:"encoding"`
}

type OrganizationFacet added in v0.2.0

type OrganizationFacet struct {
	Term     string         `json:"term"`
	Count    int            `json:"count"`
	Projects []ProjectFacet `json:"projects"`
}

type PathHierarchyTokenizer added in v0.2.0

type PathHierarchyTokenizer struct {
}

func (*PathHierarchyTokenizer) Tokenize added in v0.2.0

func (t *PathHierarchyTokenizer) Tokenize(input []byte) analysis.TokenStream

type ProjectFacet added in v0.2.0

type ProjectFacet struct {
	Term         string            `json:"term"`
	Count        int               `json:"count"`
	Repositories []RepositoryFacet `json:"repositories"`
}

type RefFacet added in v0.2.0

type RefFacet struct {
	Term  string `json:"term"`
	Count int    `json:"count"`
}

type RepositoryFacet added in v0.2.0

type RepositoryFacet struct {
	Term  string     `json:"term"`
	Count int        `json:"count"`
	Refs  []RefFacet `json:"refs"`
}

type SearchResult

type SearchResult struct {
	Query        string       `json:"query"`
	FilterParams FilterParams `json:"filterParams"`
	Time         float64      `json:"time"`
	Size         int64        `json:"size"`
	Limit        int          `json:"limit"`

	Current       int                 `json:"current"`
	Next          int                 `json:"next"`
	Hits          []Hit               `json:"hits"`
	FullRefsFacet []OrganizationFacet `json:"fullRefsFacet"`
	Facets        FacetResults        `json:"facets"`
	// contains filtered or unexported fields
}

type TermFacet added in v0.2.0

type TermFacet struct {
	Term  string `json:"term"`
	Count int    `json:"count"`
}

type TermFacets added in v0.2.0

type TermFacets []TermFacet

Jump to

Keyboard shortcuts

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