Documentation ¶
Index ¶
- Constants
- Variables
- func EnsureIndex(ctx context.Context, httpClient *http.Client, logger zerolog.Logger, ...) (*elastic.Client, errors.E)
- func GenerateCoreProperties(properties []struct{ ... })
- func GetClient(httpClient *http.Client, logger zerolog.Logger, url string) (*elastic.Client, errors.E)
- func InsertOrReplaceDocument(processor *elastic.BulkProcessor, index string, doc *Document)
- func SaveCoreProperties(ctx context.Context, log zerolog.Logger, esClient *elastic.Client, ...) errors.E
- func UpdateDocument(processor *elastic.BulkProcessor, index string, seqNo, primaryTerm int64, ...)
- func ValidAmountUnit(unit string) bool
- type AmountClaim
- type AmountClaims
- type AmountRangeClaim
- type AmountRangeClaims
- type AmountUnit
- type Claim
- type ClaimTypes
- type Confidence
- type CoreClaim
- func (cc *CoreClaim) AddMeta(claim Claim) errors.E
- func (cc CoreClaim) GetConfidence() Confidence
- func (cc CoreClaim) GetID() Identifier
- func (cc *CoreClaim) GetMeta(propID Identifier) []Claim
- func (cc *CoreClaim) GetMetaByID(id Identifier) Claim
- func (cc *CoreClaim) RemoveMetaByID(id Identifier) Claim
- func (cc *CoreClaim) VisitMeta(visitor visitor) errors.E
- type CoreDocument
- type Document
- func (d *Document) Add(claim Claim) errors.E
- func (d *Document) AllClaims() []Claim
- func (d *Document) Get(propID Identifier) []Claim
- func (d *Document) GetByID(id Identifier) Claim
- func (d Document) Reference() DocumentReference
- func (d *Document) Remove(propID Identifier) []Claim
- func (d *Document) RemoveByID(id Identifier) Claim
- func (d *Document) Visit(visitor visitor) errors.E
- type DocumentReference
- type FileClaim
- type FileClaims
- type Handler
- type Identifier
- type IdentifierClaim
- type IdentifierClaims
- type Mnemonic
- type Name
- type NoValueClaim
- type NoValueClaims
- type Params
- type ReferenceClaim
- type ReferenceClaims
- type RelationClaim
- type RelationClaims
- type Router
- func (r *Router) APIPath(name string, params Params, query string) (string, errors.E)
- func (r *Router) Error(w http.ResponseWriter, req *http.Request, code int)
- func (r *Router) Handle(name, method, path string, api bool, handler Handler) errors.E
- func (r *Router) Path(name string, params Params, query string) (string, errors.E)
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- type Score
- type Scores
- type Service
- func (s *Service) BadRequest(w http.ResponseWriter, req *http.Request, _ Params)
- func (s *Service) ConnContext(ctx context.Context, c net.Conn) context.Context
- func (s *Service) DocumentGet(w http.ResponseWriter, req *http.Request, params Params)
- func (s *Service) DocumentGetAPIGet(w http.ResponseWriter, req *http.Request, params Params)
- func (s *Service) DocumentSearch(w http.ResponseWriter, req *http.Request, _ Params)
- func (s *Service) DocumentSearchAPIGet(w http.ResponseWriter, req *http.Request, _ Params)
- func (s *Service) DocumentSearchAPIPost(w http.ResponseWriter, req *http.Request, _ Params)
- func (s *Service) DocumentSearchAmountFilterAPIGet(w http.ResponseWriter, req *http.Request, params Params)
- func (s *Service) DocumentSearchFiltersAPIGet(w http.ResponseWriter, req *http.Request, params Params)
- func (s *Service) DocumentSearchIndexFilterAPIGet(w http.ResponseWriter, req *http.Request, params Params)
- func (s *Service) DocumentSearchRelFilterAPIGet(w http.ResponseWriter, req *http.Request, params Params)
- func (s *Service) DocumentSearchSizeFilterAPIGet(w http.ResponseWriter, req *http.Request, params Params)
- func (s *Service) DocumentSearchStringFilterAPIGet(w http.ResponseWriter, req *http.Request, params Params)
- func (s *Service) DocumentSearchTimeFilterAPIGet(w http.ResponseWriter, req *http.Request, params Params)
- func (s *Service) HomeGet(w http.ResponseWriter, req *http.Request, _ Params)
- func (s *Service) HomeGetAPIGet(w http.ResponseWriter, req *http.Request, _ Params)
- func (s *Service) ImmutableFile(w http.ResponseWriter, req *http.Request, _ Params)
- func (s *Service) InternalServerError(w http.ResponseWriter, req *http.Request, _ Params)
- func (s *Service) MethodNotAllowed(w http.ResponseWriter, req *http.Request, _ Params)
- func (s *Service) NotAcceptable(w http.ResponseWriter, req *http.Request, _ Params)
- func (s *Service) NotFound(w http.ResponseWriter, req *http.Request, _ Params)
- func (s *Service) Proxy(w http.ResponseWriter, req *http.Request, _ Params)
- func (s *Service) RouteWith(router *Router, version string) (http.Handler, errors.E)
- func (s *Service) StaticFile(w http.ResponseWriter, req *http.Request, _ Params)
- type Site
- type StringClaim
- type StringClaims
- type TextClaim
- type TextClaims
- type TimeClaim
- type TimeClaims
- type TimePrecision
- type TimeRangeClaim
- type TimeRangeClaims
- type Timestamp
- type TranslatableHTMLString
- type TranslatablePlainString
- type UnknownValueClaim
- type UnknownValueClaims
- type VisitResult
Constants ¶
const (
ActiveClaimThreshold = 0.5
)
Variables ¶
var ( // CoreProperties is a map from a core property ID to a document describing it. CoreProperties = map[string]Document{} )
Functions ¶
func EnsureIndex ¶
func EnsureIndex(ctx context.Context, httpClient *http.Client, logger zerolog.Logger, url, index string, sizeField bool) (*elastic.Client, errors.E)
EnsureIndex creates an instance of the ElasticSearch client and makes sure the index for PeerDB documents exists. If not, it creates it. It does not update configuration of an existing index if it is different from what current implementation of EnsureIndex would otherwise create.
func GenerateCoreProperties ¶ added in v0.2.0
func InsertOrReplaceDocument ¶ added in v0.2.0
insertOrReplaceDocument inserts or replaces the document based on its ID.
func SaveCoreProperties ¶ added in v0.2.0
func UpdateDocument ¶ added in v0.2.0
func UpdateDocument(processor *elastic.BulkProcessor, index string, seqNo, primaryTerm int64, doc *Document)
updateDocument updates the document in the index, if it has not changed in the database since it was fetched (based on seqNo and primaryTerm).
func ValidAmountUnit ¶
Types ¶
type AmountClaim ¶
type AmountClaim struct { CoreClaim Prop DocumentReference `json:"prop"` Amount float64 `json:"amount"` Unit AmountUnit `json:"unit"` }
type AmountClaims ¶
type AmountClaims = []AmountClaim
type AmountRangeClaim ¶
type AmountRangeClaim struct { CoreClaim Prop DocumentReference `json:"prop"` Lower float64 `json:"lower"` Upper float64 `json:"upper"` Unit AmountUnit `json:"unit"` }
type AmountRangeClaims ¶
type AmountRangeClaims = []AmountRangeClaim
type AmountUnit ¶
type AmountUnit int
const ( AmountUnitCustom AmountUnit = iota AmountUnitNone AmountUnitRatio AmountUnitKilogramPerKilogram AmountUnitKilogram AmountUnitKilogramPerCubicMetre AmountUnitMetre AmountUnitSquareMetre AmountUnitMetrePerSecond AmountUnitVolt AmountUnitWatt AmountUnitPascal AmountUnitCoulomb AmountUnitJoule AmountUnitCelsius AmountUnitRadian AmountUnitHertz AmountUnitDollar AmountUnitByte AmountUnitPixel AmountUnitSecond )
func (AmountUnit) MarshalJSON ¶
func (u AmountUnit) MarshalJSON() ([]byte, error)
func (*AmountUnit) UnmarshalJSON ¶
func (u *AmountUnit) UnmarshalJSON(b []byte) error
type Claim ¶
type Claim interface { GetID() Identifier GetConfidence() Confidence AddMeta(claim Claim) errors.E GetMetaByID(id Identifier) Claim RemoveMetaByID(id Identifier) Claim VisitMeta(visitor visitor) errors.E }
type ClaimTypes ¶
type ClaimTypes struct { Identifier IdentifierClaims `json:"id,omitempty"` Reference ReferenceClaims `json:"ref,omitempty"` Text TextClaims `json:"text,omitempty"` String StringClaims `json:"string,omitempty"` Amount AmountClaims `json:"amount,omitempty"` AmountRange AmountRangeClaims `json:"amountRange,omitempty"` Relation RelationClaims `json:"rel,omitempty"` File FileClaims `json:"file,omitempty"` NoValue NoValueClaims `json:"none,omitempty"` UnknownValue UnknownValueClaims `json:"unknown,omitempty"` Time TimeClaims `json:"time,omitempty"` TimeRange TimeRangeClaims `json:"timeRange,omitempty"` }
func (*ClaimTypes) Size ¶
func (c *ClaimTypes) Size() int
func (*ClaimTypes) Visit ¶
func (c *ClaimTypes) Visit(visitor visitor) errors.E
type Confidence ¶
type Confidence = Score
type CoreClaim ¶
type CoreClaim struct { ID Identifier `json:"_id"` Confidence Confidence `json:"confidence"` Meta *ClaimTypes `json:"meta,omitempty"` }
func (CoreClaim) GetConfidence ¶
func (cc CoreClaim) GetConfidence() Confidence
func (CoreClaim) GetID ¶
func (cc CoreClaim) GetID() Identifier
func (*CoreClaim) GetMeta ¶
func (cc *CoreClaim) GetMeta(propID Identifier) []Claim
func (*CoreClaim) GetMetaByID ¶
func (cc *CoreClaim) GetMetaByID(id Identifier) Claim
func (*CoreClaim) RemoveMetaByID ¶
func (cc *CoreClaim) RemoveMetaByID(id Identifier) Claim
type CoreDocument ¶
type CoreDocument struct { ID Identifier `json:"-"` Name Name `json:"name"` Score Score `json:"score"` Scores Scores `json:"scores,omitempty"` }
type Document ¶
type Document struct { CoreDocument Mnemonic Mnemonic `json:"mnemonic,omitempty"` Active *ClaimTypes `json:"active,omitempty"` Inactive *ClaimTypes `json:"inactive,omitempty"` }
func (*Document) Get ¶
func (d *Document) Get(propID Identifier) []Claim
func (*Document) GetByID ¶
func (d *Document) GetByID(id Identifier) Claim
func (Document) Reference ¶
func (d Document) Reference() DocumentReference
func (*Document) Remove ¶
func (d *Document) Remove(propID Identifier) []Claim
func (*Document) RemoveByID ¶
func (d *Document) RemoveByID(id Identifier) Claim
type DocumentReference ¶
type DocumentReference struct { ID Identifier `json:"_id"` Name Name `json:"name"` Score Score `json:"score"` Scores Scores `json:"scores,omitempty"` }
func GetCorePropertyReference ¶ added in v0.2.0
func GetCorePropertyReference(mnemonic string) DocumentReference
type FileClaim ¶
type FileClaim struct { CoreClaim Prop DocumentReference `json:"prop"` Type string `json:"type"` URL string `json:"url"` Preview []string `json:"preview,omitempty"` }
type FileClaims ¶
type FileClaims = []FileClaim
type Identifier ¶
type Identifier string
func GetCorePropertyID ¶ added in v0.2.0
func GetCorePropertyID(mnemonic string) Identifier
func GetID ¶
func GetID(namespace uuid.UUID, args ...interface{}) Identifier
type IdentifierClaim ¶
type IdentifierClaim struct { CoreClaim Prop DocumentReference `json:"prop"` Identifier string `json:"id"` }
type IdentifierClaims ¶
type IdentifierClaims = []IdentifierClaim
type Name ¶
type Name = TranslatablePlainString
type NoValueClaim ¶
type NoValueClaim struct { CoreClaim Prop DocumentReference `json:"prop"` }
type NoValueClaims ¶
type NoValueClaims = []NoValueClaim
type ReferenceClaim ¶
type ReferenceClaim struct { CoreClaim Prop DocumentReference `json:"prop"` IRI string `json:"iri"` }
type ReferenceClaims ¶
type ReferenceClaims = []ReferenceClaim
type RelationClaim ¶
type RelationClaim struct { CoreClaim Prop DocumentReference `json:"prop"` To DocumentReference `json:"to"` }
type RelationClaims ¶
type RelationClaims = []RelationClaim
type Router ¶
type Router struct { NotFound Handler MethodNotAllowed Handler NotAcceptable Handler Panic func(w http.ResponseWriter, req *http.Request, err interface{}) // contains filtered or unexported fields }
type Service ¶
type Service struct { ESClient *elastic.Client Log zerolog.Logger Sites map[string]Site Development string Version string BuildTimestamp string Revision string Router *Router // contains filtered or unexported fields }
func NewService ¶
func (*Service) BadRequest ¶
func (*Service) ConnContext ¶
func (*Service) DocumentGet ¶ added in v0.2.0
DocumentGet is a GET/HEAD HTTP request handler which returns HTML frontend for a document given its ID as a parameter.
func (*Service) DocumentGetAPIGet ¶ added in v0.2.0
DocumentGetAPIGet is a GET/HEAD HTTP request handler which returns a document given its ID as a parameter. It supports compression based on accepted content encoding and range requests.
func (*Service) DocumentSearch ¶ added in v0.2.0
DocumentSearch is a GET/HEAD HTTP request handler which returns HTML frontend for searching documents. If search state is invalid, it redirects to a valid one.
func (*Service) DocumentSearchAPIGet ¶ added in v0.2.0
DocumentSearchAPIGet is a GET/HEAD HTTP request handler and it searches ElasticSearch index using provided search state and returns to the client a JSON with an array of IDs of found documents. If search state is invalid, it returns correct query parameters as JSON. It supports compression based on accepted content encoding and range requests. It returns search metadata (e.g., total results) as PeerDB HTTP response headers.
func (*Service) DocumentSearchAPIPost ¶ added in v0.2.0
DocumentSearchAPIPost is a POST HTTP request handler which stores the search state and returns query parameters for the GET endpoint as JSON or redirects to the GET endpoint based on search ID.
func (*Service) DocumentSearchAmountFilterAPIGet ¶ added in v0.2.0
func (*Service) DocumentSearchFiltersAPIGet ¶ added in v0.2.0
func (*Service) DocumentSearchIndexFilterAPIGet ¶ added in v0.2.0
func (*Service) DocumentSearchRelFilterAPIGet ¶ added in v0.2.0
func (*Service) DocumentSearchSizeFilterAPIGet ¶ added in v0.2.0
func (*Service) DocumentSearchStringFilterAPIGet ¶ added in v0.2.0
func (*Service) DocumentSearchTimeFilterAPIGet ¶ added in v0.2.0
func (*Service) HomeGet ¶ added in v0.2.0
HomeGet is a GET/HEAD HTTP request handler which returns HTML frontend for the home page.
func (*Service) HomeGetAPIGet ¶ added in v0.2.0
func (*Service) ImmutableFile ¶ added in v0.2.0
func (*Service) InternalServerError ¶
func (*Service) MethodNotAllowed ¶
func (*Service) NotAcceptable ¶
func (*Service) NotFound ¶
NotFound is a HTTP request handler which returns a 404 error to the client.
func (*Service) StaticFile ¶
type StringClaim ¶
type StringClaim struct { CoreClaim Prop DocumentReference `json:"prop"` String string `json:"string"` }
type StringClaims ¶
type StringClaims = []StringClaim
type TextClaim ¶
type TextClaim struct { CoreClaim Prop DocumentReference `json:"prop"` HTML TranslatableHTMLString `json:"html"` }
type TextClaims ¶
type TextClaims = []TextClaim
type TimeClaim ¶
type TimeClaim struct { CoreClaim Prop DocumentReference `json:"prop"` Timestamp Timestamp `json:"timestamp"` Precision TimePrecision `json:"precision"` }
type TimeClaims ¶
type TimeClaims = []TimeClaim
type TimePrecision ¶
type TimePrecision int
const ( TimePrecisionGigaYears TimePrecision = iota TimePrecisionHundredMegaYears TimePrecisionTenMegaYears TimePrecisionMegaYears TimePrecisionHundredKiloYears TimePrecisionTenKiloYears TimePrecisionKiloYears TimePrecisionHundredYears TimePrecisionTenYears TimePrecisionYear TimePrecisionMonth TimePrecisionDay TimePrecisionHour TimePrecisionMinute TimePrecisionSecond )
func (TimePrecision) MarshalJSON ¶
func (p TimePrecision) MarshalJSON() ([]byte, error)
func (*TimePrecision) UnmarshalJSON ¶
func (p *TimePrecision) UnmarshalJSON(b []byte) error
type TimeRangeClaim ¶
type TimeRangeClaim struct { CoreClaim Prop DocumentReference `json:"prop"` Lower Timestamp `json:"lower"` Upper Timestamp `json:"upper"` Precision TimePrecision `json:"precision"` }
type TimeRangeClaims ¶
type TimeRangeClaims = []TimeRangeClaim
type TranslatableHTMLString ¶
Language to HTML string mapping.
type TranslatablePlainString ¶
Language to plain string mapping.
type UnknownValueClaim ¶
type UnknownValueClaim struct { CoreClaim Prop DocumentReference `json:"prop"` }
type UnknownValueClaims ¶
type UnknownValueClaims = []UnknownValueClaim
type VisitResult ¶
type VisitResult int
const ( Keep VisitResult = iota KeepAndStop Drop DropAndStop )
Source Files ¶
- document.go
- document_get.go
- document_search.go
- document_search_amount_filter.go
- document_search_filters.go
- document_search_index_filter.go
- document_search_rel_filter.go
- document_search_size_filter.go
- document_search_string_filter.go
- document_search_time_filter.go
- home.go
- index.go
- properties.go
- router.go
- service.go
- utils.go