search

package
v0.0.0-...-016f308 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2015 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package search describes and answers Camlistore search queries.

Many of the search methods or functions provide results that are ordered by modification time, or at least depend on modification times. In that context, (un)deletions (of permanodes, or attributes) are not considered modifications and therefore the time at which they occured does not affect the result.

Index

Constants

View Source
const MaxImageSize = 2000

MaxImageSize is the maximum width or height in pixels that we will serve image thumbnails at. It is used in the search result UI.

Variables

This section is empty.

Functions

func SearchHelp

func SearchHelp() string

SearchHelp returns JSON of an array of predicate names and descriptions.

Types

type ClaimConstraint

type ClaimConstraint struct {
	SignedBy     string    `json:"signedBy"` // identity
	SignedAfter  time.Time `json:"signedAfter"`
	SignedBefore time.Time `json:"signedBefore"`
}

type ClaimsItem

type ClaimsItem struct {
	BlobRef   blob.Ref       `json:"blobref"`
	Signer    blob.Ref       `json:"signer"`
	Permanode blob.Ref       `json:"permanode"`
	Date      types.Time3339 `json:"date"`
	Type      string         `json:"type"`
	Attr      string         `json:"attr,omitempty"`
	Value     string         `json:"value,omitempty"`
}

A ClaimsItem is an item returned from $searchRoot/camli/search/claims.

type ClaimsRequest

type ClaimsRequest struct {
	Permanode blob.Ref

	// AttrFilter optionally filters claims about the given attribute.
	// If empty, all claims for the given Permanode are returned.
	AttrFilter string
}

ClaimsRequest is a request to get a ClaimsResponse.

func (*ClaimsRequest) URLSuffix

func (r *ClaimsRequest) URLSuffix() string

type ClaimsResponse

type ClaimsResponse struct {
	Claims []*ClaimsItem `json:"claims"`
}

ClaimsResponse is the JSON response from $searchRoot/camli/search/claims.

type Constraint

type Constraint struct {
	// If Logical is non-nil, all other fields are ignored.
	Logical *LogicalConstraint `json:"logical,omitempty"`

	// Anything, if true, matches all blobs.
	Anything bool `json:"anything,omitempty"`

	CamliType     string `json:"camliType,omitempty"`    // camliType of the JSON blob
	AnyCamliType  bool   `json:"anyCamliType,omitempty"` // if true, any camli JSON blob matches
	BlobRefPrefix string `json:"blobRefPrefix,omitempty"`

	File *FileConstraint `json:"file,omitempty"`
	Dir  *DirConstraint  `json:"dir,omitempty"`

	Claim    *ClaimConstraint `json:"claim,omitempty"`
	BlobSize *IntConstraint   `json:"blobSize,omitempty"`

	Permanode *PermanodeConstraint `json:"permanode,omitempty"`
	// contains filtered or unexported fields
}

Constraint specifies a blob matching constraint. A blob matches if it matches all non-zero fields' predicates. A zero constraint matches nothing.

type DescribeError

type DescribeError map[string]error

func (DescribeError) Error

func (de DescribeError) Error() string

type DescribeRequest

type DescribeRequest struct {
	// BlobRefs are the blobs to describe. If length zero, BlobRef
	// is used.
	BlobRefs []blob.Ref `json:"blobrefs,omitempty"`

	// BlobRef is the blob to describe.
	BlobRef blob.Ref `json:"blobref,omitempty"`

	// Depth is the optional traversal depth to describe from the
	// root BlobRef. If zero, a default is used.
	// Depth is deprecated and will be removed. Use Rules instead.
	Depth int `json:"depth,omitempty"`

	// MaxDirChildren is the requested optional limit to the number
	// of children that should be fetched when describing a static
	// directory. If zero, a default is used.
	MaxDirChildren int `json:"maxDirChildren,omitempty"`

	// At specifies the time which we wish to see the state of
	// this blob.  If zero (unspecified), all claims will be
	// considered, otherwise, any claims after this date will not
	// be considered.
	At types.Time3339 `json:"at"`

	// ThumbnailSize sets the max dimension for the thumbnail ULR generated,
	// or zero for none
	ThumbnailSize int `json:"thumbnailSize,omitempty"`

	// Rules specifies a set of rules to instruct how to keep
	// expanding the described set. All rules are tested and
	// matching rules grow the the response set until all rules no
	// longer match or internal limits are hit.
	Rules []*DescribeRule `json:"rules,omitempty"`
	// contains filtered or unexported fields
}

func (*DescribeRequest) Describe

func (dr *DescribeRequest) Describe(br blob.Ref, depth int)

Describe starts a lookup of br, down to the provided depth. It returns immediately.

func (*DescribeRequest) DescribeSync

func (dr *DescribeRequest) DescribeSync(br blob.Ref) (*DescribedBlob, error)

func (*DescribeRequest) DescribedBlobStr

func (dr *DescribeRequest) DescribedBlobStr(blobstr string) *DescribedBlob

Given a blobref string returns a Description or nil. dr may be nil itself.

func (*DescribeRequest) Result

func (dr *DescribeRequest) Result() (desmap map[string]*DescribedBlob, err error)

Result waits for all outstanding lookups to complete and returns the map of blobref (strings) to their described results. The returned error is non-nil if any errors occured, and will be of type DescribeError.

func (*DescribeRequest) URLSuffix

func (r *DescribeRequest) URLSuffix() string

URLSuffix returns the URL suffix for GET requests. This is deprecated.

func (*DescribeRequest) URLSuffixPost

func (r *DescribeRequest) URLSuffixPost() string

URLSuffixPost returns the URL suffix for POST requests.

type DescribeResponse

type DescribeResponse struct {
	Meta MetaMap `json:"meta"`
}

DescribeResponse is the JSON response from $searchRoot/camli/search/describe.

type DescribeRule

type DescribeRule struct {

	// IsResultRoot, if true, only matches if the blob was part of
	// the original search results, not a blob expanded later.
	IfResultRoot bool `json:"ifResultRoot,omitempty"`

	// IfCamliNodeType matches if the "camliNodeType" attribute
	// equals this value.
	IfCamliNodeType string `json:"ifCamliNodeType,omitempty"`

	// Attrs lists attributes to describe. A special case
	// is if the value ends in "*", which matches prefixes
	// (e.g. "camliPath:*" or "*").
	Attrs []string `json:"attrs,omitempty"`

	// Additional rules to run on the described results of Attrs.
	Rules []*DescribeRule `json:"rules,omitempty"`
	// contains filtered or unexported fields
}

type DescribedBlob

type DescribedBlob struct {
	Request *DescribeRequest `json:"-"`

	BlobRef   blob.Ref `json:"blobRef"`
	CamliType string   `json:"camliType,omitempty"`
	Size      int64    `json:"size,"`

	// if camliType "permanode"
	Permanode *DescribedPermanode `json:"permanode,omitempty"`

	// if camliType "file"
	File *camtypes.FileInfo `json:"file,omitempty"`
	// if camliType "directory"
	Dir *camtypes.FileInfo `json:"dir,omitempty"`
	// if camliType "file", and File.IsImage()
	Image *camtypes.ImageInfo `json:"image,omitempty"`
	// if camliType "file" and media file
	MediaTags map[string]string `json:"mediaTags,omitempty"`

	// if camliType "directory"
	DirChildren []blob.Ref `json:"dirChildren,omitempty"`

	Thumbnail       string `json:"thumbnailSrc,omitempty"`
	ThumbnailWidth  int    `json:"thumbnailWidth,omitempty"`
	ThumbnailHeight int    `json:"thumbnailHeight,omitempty"`

	// Stub is set if this is not loaded, but referenced.
	Stub bool `json:"-"`
}

func (*DescribedBlob) ContentRef

func (b *DescribedBlob) ContentRef() (br blob.Ref, ok bool)

func (*DescribedBlob) Description

func (b *DescribedBlob) Description() string

func (*DescribedBlob) DirMembers

func (b *DescribedBlob) DirMembers() []*DescribedBlob

func (*DescribedBlob) DomID

func (b *DescribedBlob) DomID() string

func (*DescribedBlob) Members

func (b *DescribedBlob) Members() []*DescribedBlob

Members returns all of b's children, as given by b's camliMember and camliPath:* attributes. Only the first entry for a given camliPath attribute is used.

func (*DescribedBlob) PeerBlob

func (b *DescribedBlob) PeerBlob(br blob.Ref) *DescribedBlob

PeerBlob returns a DescribedBlob for the provided blobref.

Unlike DescribedBlobStr, the returned DescribedBlob is never nil.

If the blob was never loaded along with the the receiver (or if the receiver is nil), a stub DescribedBlob is returned with its Stub field set true.

func (*DescribedBlob) PermanodeDir

func (b *DescribedBlob) PermanodeDir() (path []blob.Ref, fi *camtypes.FileInfo, ok bool)

PermanodeDir returns in path the blobref of the described permanode and the blobref of its Directory camliContent. If b isn't a permanode, or doesn't have a camliContent that is a directory blob, ok is false.

func (*DescribedBlob) PermanodeFile

func (b *DescribedBlob) PermanodeFile() (path []blob.Ref, fi *camtypes.FileInfo, ok bool)

PermanodeFile returns in path the blobref of the described permanode and the blobref of its File camliContent. If b isn't a permanode, or doesn't have a camliContent that is a file blob, ok is false.

func (*DescribedBlob) Title

func (b *DescribedBlob) Title() string

type DescribedPermanode

type DescribedPermanode struct {
	Attr    url.Values `json:"attr"` // a map[string][]string
	ModTime time.Time  `json:"modtime,omitempty"`
}

func (*DescribedPermanode) IsContainer

func (dp *DescribedPermanode) IsContainer() bool

IsContainer returns whether the permanode has either named ("camliPath:"-prefixed) or unnamed ("camliMember") member attributes.

type DirConstraint

type DirConstraint struct {
	FileName *StringConstraint

	TopFileSize,
	TopFileCount,
	FileSize,
	FileCount *IntConstraint
}

type EXIFConstraint

type EXIFConstraint struct {
}

type EdgeItem

type EdgeItem struct {
	From     blob.Ref `json:"from"`
	FromType string   `json:"fromType"`
}

An EdgeItem is an item returned from $searchRoot/camli/search/edgesto.

type EdgesRequest

type EdgesRequest struct {
	// The blob we want to find as a reference.
	ToRef blob.Ref
}

EdgesRequest is a request to get an EdgesResponse.

type EdgesResponse

type EdgesResponse struct {
	ToRef   blob.Ref    `json:"toRef"`
	EdgesTo []*EdgeItem `json:"edgesTo"`
}

EdgesResponse is the JSON response from $searchRoot/camli/search/edgesto.

type FileConstraint

type FileConstraint struct {
	FileSize *IntConstraint    `json:"fileSize,omitempty"`
	FileName *StringConstraint `json:"fileName,omitempty"`
	MIMEType *StringConstraint `json:"mimeType,omitempty"`
	Time     *TimeConstraint   `json:"time,omitempty"`
	ModTime  *TimeConstraint   `json:"modTime,omitempty"`

	// WholeRef if non-zero only matches if the entire checksum of the
	// file (the concatenation of all its blobs) is equal to the
	// provided blobref. The index may not have every file's digest for
	// every known hash algorithm.
	WholeRef blob.Ref `json:"wholeRef,omitempty"`

	// For images:
	IsImage  bool                `json:"isImage,omitempty"`
	EXIF     *EXIFConstraint     `json:"exif,omitempty"` // TODO: implement
	Width    *IntConstraint      `json:"width,omitempty"`
	Height   *IntConstraint      `json:"height,omitempty"`
	WHRatio  *FloatConstraint    `json:"widthHeightRation,omitempty"`
	Location *LocationConstraint `json:"location,omitempty"`

	// MediaTag is for ID3 (and similar) embedded metadata in files.
	MediaTag *MediaTagConstraint `json:"mediaTag,omitempty"`
}

type FloatConstraint

type FloatConstraint struct {
	// Min and Max are both optional and inclusive bounds.
	// Zero means don't check.
	Min     float64 `json:"min,omitempty"`
	Max     float64 `json:"max,omitempty"`
	ZeroMin bool    `json:"zeroMin,omitempty"` // if true, min is actually zero
	ZeroMax bool    `json:"zeroMax,omitempty"` // if true, max is actually zero
}

A FloatConstraint specifies constraints on a float.

type GetRecentPermanoder

type GetRecentPermanoder interface {
	// GetRecentPermanodes returns recently-modified permanodes.
	// This is a higher-level query returning more metadata than the index.GetRecentPermanodes,
	// which only scans the blobrefs but doesn't return anything about the permanodes.
	GetRecentPermanodes(*RecentRequest) (*RecentResponse, error)
}

GetRecentPermanoder is the interface containing the GetRecentPermanodes method.

type Handler

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

Handler handles search queries.

func NewHandler

func NewHandler(index index.Interface, owner blob.Ref) *Handler

func (*Handler) Describe

func (sh *Handler) Describe(dr *DescribeRequest) (dres *DescribeResponse, err error)

func (*Handler) EdgesTo

func (sh *Handler) EdgesTo(req *EdgesRequest) (*EdgesResponse, error)

EdgesTo returns edges that reference req.RefTo. It filters out since-deleted permanode edges.

func (*Handler) GetClaims

func (sh *Handler) GetClaims(req *ClaimsRequest) (*ClaimsResponse, error)

GetClaims returns the claims on req.Permanode signed by sh.owner.

func (*Handler) GetPermanodesWithAttr

func (sh *Handler) GetPermanodesWithAttr(req *WithAttrRequest) (*WithAttrResponse, error)

GetPermanodesWithAttr returns permanodes with attribute req.Attr having the req.Value as a value. See WithAttrRequest for more details about the query.

func (*Handler) GetRecentPermanodes

func (sh *Handler) GetRecentPermanodes(req *RecentRequest) (*RecentResponse, error)

GetRecentPermanodes returns recently-modified permanodes.

func (*Handler) GetSignerPaths

func (sh *Handler) GetSignerPaths(req *SignerPathsRequest) (*SignerPathsResponse, error)

GetSignerPaths returns paths with a target of req.Target.

func (*Handler) Index

func (h *Handler) Index() index.Interface

func (*Handler) NewDescribeRequest

func (sh *Handler) NewDescribeRequest() *DescribeRequest

NewDescribeRequest returns a new DescribeRequest holding the state of blobs and their summarized descriptions. Use DescribeBlob one or more times before calling Result.

func (*Handler) Owner

func (h *Handler) Owner() blob.Ref

Owner returns Handler owner's public key blobref.

func (*Handler) Query

func (h *Handler) Query(rawq *SearchQuery) (*SearchResult, error)

func (*Handler) SendStatusUpdate

func (h *Handler) SendStatusUpdate(status json.RawMessage)

SendStatusUpdate sends a JSON status map to any connected WebSocket clients.

func (*Handler) ServeHTTP

func (sh *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

func (*Handler) SetCorpus

func (h *Handler) SetCorpus(c *index.Corpus)

type IntConstraint

type IntConstraint struct {
	// Min and Max are both optional and inclusive bounds.
	// Zero means don't check.
	Min     int64 `json:"min,omitempty"`
	Max     int64 `json:"max,omitempty"`
	ZeroMin bool  `json:"zeroMin,omitempty"` // if true, min is actually zero
	ZeroMax bool  `json:"zeroMax,omitempty"` // if true, max is actually zero
}

An IntConstraint specifies constraints on an integer.

type LocationConstraint

type LocationConstraint struct {
	// Any, if true, matches any photo with a known location.
	Any bool

	// North, West, East, and South define a region in which a photo
	// must be in order to match.
	North float64
	West  float64
	East  float64
	South float64
}

type LogicalConstraint

type LogicalConstraint struct {
	Op string      `json:"op"` // "and", "or", "xor", "not"
	A  *Constraint `json:"a"`
	B  *Constraint `json:"b"` // only valid if Op != "not"
}

type MediaTagConstraint

type MediaTagConstraint struct {
	// Tag is the tag to match.
	// For ID3, this includes: title, artist, album, genre, musicbrainzalbumid, year, track, disc, mediaref, durationms.
	Tag string `json:"tag"`

	String *StringConstraint `json:"string,omitempty"`
	Int    *IntConstraint    `json:"int,omitempty"`
}

type MetaMap

type MetaMap map[string]*DescribedBlob

A MetaMap is a map from blobref to a DescribedBlob.

func (MetaMap) Get

func (m MetaMap) Get(br blob.Ref) *DescribedBlob

type PermanodeConstraint

type PermanodeConstraint struct {
	// At specifies the time at which to pretend we're resolving attributes.
	// Attribute claims after this point in time are ignored.
	// If zero, the current time is used.
	At time.Time `json:"at,omitempty"`

	// ModTime optionally matches on the last modtime of the permanode.
	ModTime *TimeConstraint `json:"modTime,omitempty"`

	// Time optionally matches the permanode's time. A Permanode
	// may not have a known time. If the permanode does not have a
	// known time, one may be guessed if the top-level search
	// parameters request so.
	Time *TimeConstraint `json:"time,omitempty"`

	// Attr optionally specifies the attribute to match.
	// e.g. "camliContent", "camliMember", "tag"
	// This is required if any of the items below are used.
	Attr string `json:"attr,omitempty"`

	// SkipHidden skips hidden or other boring files.
	SkipHidden bool `json:"skipHidden,omitempty"`

	// NumValue optionally tests the number of values this
	// permanode has for Attr.
	NumValue *IntConstraint `json:"numValue,omitempty"`

	// ValueAll modifies the matching behavior when an attribute
	// is multi-valued.  By default, when ValueAll is false, only
	// one value of a multi-valued attribute needs to match. If
	// ValueAll is true, all attributes must match.
	ValueAll bool `json:"valueAllMatch,omitempty"`

	// Value specifies an exact string to match.
	// This is a convenience form for the simple case of exact
	// equality. The same can be accomplished with ValueMatches.
	Value string `json:"value,omitempty"` // if non-zero, absolute match

	// ValueMatches optionally specifies a StringConstraint to
	// match the value against.
	ValueMatches *StringConstraint `json:"valueMatches,omitempty"`

	// ValueMatchesInt optionally specifies an IntConstraint to match
	// the value against. Non-integer values will not match.
	ValueMatchesInt *IntConstraint `json:"valueMatchesInt,omitempty"`

	// ValueMatchesFloat optionally specifies a FloatConstraint to match
	// the value against. Non-float values will not match.
	ValueMatchesFloat *FloatConstraint `json:"valueMatchesFloat,omitempty"`

	// ValueInSet optionally specifies a sub-query which the value
	// (which must be a blobref) must be a part of.
	ValueInSet *Constraint `json:"valueInSet,omitempty"`

	// Relation optionally specifies a constraint based on relations
	// to other permanodes (e.g. camliMember or camliPath sets).
	// You can use it to test the properties of a parent, ancestor,
	// child, or progeny.
	Relation *RelationConstraint `json:"relation,omitempty"`

	// Location optionally restricts matches to permanodes having
	// this location. This only affects permanodes with a known
	// type to have an lat/long location.
	Location *LocationConstraint `json:"location,omitempty"`

	// Continue is for internal use.
	Continue *PermanodeContinueConstraint `json:"-"`
}

PermanodeConstraint matches permanodes.

type PermanodeContinueConstraint

type PermanodeContinueConstraint struct {
	// LastMod if non-zero is the modtime of the last item
	// that was seen. One of this or LastCreated will be set.
	LastMod time.Time

	// LastCreated if non-zero is the creation time of the last
	// item that was seen.
	LastCreated time.Time

	// Last is the last blobref that was shown at the time
	// given in ModLessEqual or CreateLessEqual.
	// This is used as a tie-breaker.
	// If the time is equal, permanodes <= this are not matched.
	// If the time is past this in the scroll position, then this
	// field is ignored.
	Last blob.Ref
}

type QueryDescriber

type QueryDescriber interface {
	Query(*SearchQuery) (*SearchResult, error)
	Describe(*DescribeRequest) (*DescribeResponse, error)
}

type RecentItem

type RecentItem struct {
	BlobRef blob.Ref       `json:"blobref"`
	ModTime types.Time3339 `json:"modtime"`
	Owner   blob.Ref       `json:"owner"`
}

A RecentItem is an item returned from $searchRoot/camli/search/recent in the "recent" list.

type RecentRequest

type RecentRequest struct {
	N             int       // if zero, default number of results
	Before        time.Time // if zero, now
	ThumbnailSize int       // if zero, no thumbnails
}

RecentRequest is a request to get a RecentResponse.

func (*RecentRequest) URLSuffix

func (r *RecentRequest) URLSuffix() string

type RecentResponse

type RecentResponse struct {
	Recent []*RecentItem `json:"recent"`
	Meta   MetaMap       `json:"meta"`

	Error     string `json:"error,omitempty"`
	ErrorType string `json:"errorType,omitempty"`
}

RecentResponse is the JSON response from $searchRoot/camli/search/recent.

func (*RecentResponse) Err

func (r *RecentResponse) Err() error

type RelationConstraint

type RelationConstraint struct {
	// Relation must be one of:
	//   * "child"
	//   * "parent" (immediate parent only)
	//   * "progeny" (any level down)
	//   * "ancestor" (any level up)
	Relation string

	// EdgeType optionally specifies an edge type.
	// By default it matches "camliMember" and "camliPath:*".
	EdgeType string

	// After finding all the nodes matching the Relation and
	// EdgeType, either one or all (depending on whether Any or
	// All is set) must then match for the RelationConstraint
	// itself to match.
	//
	// It is an error to set both.
	Any, All *Constraint
}

type SearchQuery

type SearchQuery struct {

	// Expression is a textual search query in minimal form,
	// e.g. "hawaii before:2008" or "tag:foo" or "foo" or "location:portland"
	// See expr.go and expr_test.go for all the operators.
	Expression string      `json:"expression,omitempty"`
	Constraint *Constraint `json:"constraint,omitempty"`

	// Limit is the maximum number of returned results. A negative value means no
	// limit. If unspecified, a default (of 200) will be used.
	Limit int `json:"limit,omitempty"`

	// Sort specifies how the results will be sorted. It defaults to CreatedDesc when the
	// query is about permanodes only.
	Sort SortType `json:"sort,omitempty"`

	// Around specifies that the results, after sorting, should be centered around
	// this result. If Around is not found the returned results will be empty.
	// If both Continue and Around are set, an error is returned.
	Around blob.Ref `json:"around,omitempty"`

	// Continue specifies the opaque token (as returned by a
	// SearchResult) for where to continue fetching results when
	// the Limit on a previous query was interrupted.
	// Continue is only valid for the same query (Expression or Constraint),
	// Limit, and Sort values.
	// If empty, the top-most query results are returned, as given
	// by Limit and Sort.
	// Continue is not compatible with the Around option.
	Continue string `json:"continue,omitempty"`

	// If Describe is specified, the matched blobs are also described,
	// as if the Describe.BlobRefs field was populated.
	Describe *DescribeRequest `json:"describe,omitempty"`
}

func (*SearchQuery) URLSuffix

func (q *SearchQuery) URLSuffix() string

type SearchResult

type SearchResult struct {
	Blobs    []*SearchResultBlob `json:"blobs"`
	Describe *DescribeResponse   `json:"description"`

	// Continue optionally specifies the continuation token to to
	// continue fetching results in this result set, if interrupted
	// by a Limit.
	Continue string `json:"continue,omitempty"`
}

SearchResult is the result of the Search method for a given SearchQuery.

type SearchResultBlob

type SearchResultBlob struct {
	Blob blob.Ref `json:"blob"`
}

func (*SearchResultBlob) String

func (r *SearchResultBlob) String() string

type SignerAttrValueResponse

type SignerAttrValueResponse struct {
	Permanode blob.Ref `json:"permanode"`
	Meta      MetaMap  `json:"meta"`
}

SignerAttrValueResponse is the JSON response to $search/camli/search/signerattrvalue

type SignerPathsItem

type SignerPathsItem struct {
	ClaimRef blob.Ref `json:"claimRef"`
	BaseRef  blob.Ref `json:"baseRef"`
	Suffix   string   `json:"suffix"`
}

A SignerPathsItem is an item returned from $searchRoot/camli/search/signerpaths.

type SignerPathsRequest

type SignerPathsRequest struct {
	Signer blob.Ref
	Target blob.Ref
}

SignerPathsRequest is a request to get a SignerPathsResponse.

type SignerPathsResponse

type SignerPathsResponse struct {
	Paths []*SignerPathsItem `json:"paths"`
	Meta  MetaMap            `json:"meta"`
}

SignerPathsResponse is the JSON response from $searchRoot/camli/search/signerpaths.

type SortType

type SortType int
const (
	UnspecifiedSort SortType = iota
	Unsorted
	LastModifiedDesc
	LastModifiedAsc
	CreatedDesc
	CreatedAsc
	BlobRefAsc
)

func (SortType) MarshalJSON

func (t SortType) MarshalJSON() ([]byte, error)

func (*SortType) UnmarshalJSON

func (t *SortType) UnmarshalJSON(v []byte) error

type StringConstraint

type StringConstraint struct {
	Empty           bool           `json:"empty,omitempty"` // matches empty string
	Equals          string         `json:"equals,omitempty"`
	Contains        string         `json:"contains,omitempty"`
	HasPrefix       string         `json:"hasPrefix,omitempty"`
	HasSuffix       string         `json:"hasSuffix,omitempty"`
	ByteLength      *IntConstraint `json:"byteLength,omitempty"` // length in bytes (not chars)
	CaseInsensitive bool           `json:"caseInsensitive,omitempty"`
}

A StringConstraint specifies constraints on a string. All non-zero must match.

type TimeConstraint

type TimeConstraint struct {
	Before types.Time3339 `json:"before"` // <
	After  types.Time3339 `json:"after"`  // >=

	// TODO: this won't JSON-marshal/unmarshal well. Make a time.Duration marshal type?
	// Likewise with time that supports omitempty?
	InLast time.Duration `json:"inLast"` // >=
}

type WithAttrItem

type WithAttrItem struct {
	Permanode blob.Ref `json:"permanode"`
}

A WithAttrItem is an item returned from $searchRoot/camli/search/permanodeattr.

type WithAttrRequest

type WithAttrRequest struct {
	N      int      // max number of results
	Signer blob.Ref // if nil, will use the server's default owner (if configured)
	// Requested attribute. If blank, all attributes are searched (for Value)
	// as fulltext.
	Attr string
	// Value of the requested attribute. If blank, permanodes which have
	// request.Attr as an attribute are searched.
	Value         string
	Fuzzy         bool // fulltext search (if supported).
	ThumbnailSize int  // if zero, no thumbnails
}

WithAttrRequest is a request to get a WithAttrResponse.

func (*WithAttrRequest) URLSuffix

func (r *WithAttrRequest) URLSuffix() string

type WithAttrResponse

type WithAttrResponse struct {
	WithAttr []*WithAttrItem `json:"withAttr"`
	Meta     MetaMap         `json:"meta"`

	Error     string `json:"error,omitempty"`
	ErrorType string `json:"errorType,omitempty"`
}

WithAttrResponse is the JSON response from $searchRoot/camli/search/permanodeattr.

func (*WithAttrResponse) Err

func (r *WithAttrResponse) Err() error

Jump to

Keyboard shortcuts

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