Documentation
¶
Index ¶
- type HarvestElement
- type HarvestSegment
- type Hit
- func (hit *Hit) PopulateMath() error
- func (hit *Hit) PopulateMathSource() error
- func (hit *Hit) PopulateSubsitutions(res *Result) error
- func (hit *Hit) UnmarshalElasticDocument(obj *elasticutils.Object) (err error)
- func (hit *Hit) UnmarshalElasticHighlight(obj *elasticutils.Object) (err error)
- func (hit *Hit) UnmarshalJSON(bytes []byte) error
- type Kind
- type MathFormula
- type QueryVariable
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HarvestElement ¶
type HarvestElement struct { Metadata interface{} `json:"metadata"` // Arbitrary document metadata Segment string `json:"segment,omitempty"` // Name of the segment this document belongs to Text string `json:"text"` // Text of this element MWSPaths map[int64]map[string]MathFormula `json:"mws_id,omitempty"` // information about each identifier within this document MWSNumbers []int64 `json:"mws_ids,omitempty"` // list of identifiers within this document MathSource map[string]string `json:"math"` // Source of replaced math elements within this document }
HarvestElement represents an <mws:data> harvest node, which can be contained both within ElasticSearch and MWS
func (*HarvestElement) UnmarshalXML ¶
func (he *HarvestElement) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
UnmarshalXML unmarshals xml into a harvest element
type HarvestSegment ¶
type HarvestSegment struct { ID string `json:"segment"` Hash string `json:"hash"` // the hash of this segment (if any) Touched bool `json:"touched"` // has this segment been touched within recent changes }
HarvestSegment represents the name of the segment
type Hit ¶
type Hit struct { ID string `json:"id,omitempty"` // the (possibly internal) id of this hit URL string `json:"url,omitempty"` // the url of the document returned XPath string `json:"xpath"` // the xpath of the query term to the formulae referred to by this id Element *HarvestElement `json:"source,omitempty"` // the raw harvest element (if any) Score float64 `json:"score,omitempty"` // score of this hit Snippets []string `json:"snippets,omitempty"` // extracts of this hit (if any) Math []*MathFormula `json:"math_ids"` // math found within this hit }
Hit represents a single Hit
func (*Hit) PopulateMath ¶
PopulateMath populates the 'Math' property of this hit using the 'math' property of the result
func (*Hit) PopulateMathSource ¶
PopulateMathSource populates the maths sources for all mathFormulae within this hit
func (*Hit) PopulateSubsitutions ¶
PopulateSubsitutions populates the subsitutions field of all found math formulae in this hit
func (*Hit) UnmarshalElasticDocument ¶
func (hit *Hit) UnmarshalElasticDocument(obj *elasticutils.Object) (err error)
UnmarshalElasticDocument unmarshals a document hit from elasticsearch If ids is non-nil use only ids for Math Elements
func (*Hit) UnmarshalElasticHighlight ¶
func (hit *Hit) UnmarshalElasticHighlight(obj *elasticutils.Object) (err error)
UnmarshalElasticHighlight populates a document hit with a highlight hit
func (*Hit) UnmarshalJSON ¶
UnmarshalJSON unmarshals a json hit
type Kind ¶
type Kind string
Kind represents the kind of result being returned
const ( // EmptyKind is a ressult in response to the empty query EmptyKind Kind = "" // MathWebSearchKind is a result in represonse to a MathWebSearch query MathWebSearchKind Kind = "mwsd" // ElasticDocumentKind is a result returned from the document query ElasticDocumentKind Kind = "elastic-document" // ElasticKind is a result returned from the document + highlight query ElasticKind Kind = "elastic" // TemaSearchKind is a result returned from a combined elastic + MathWebSearch Query TemaSearchKind Kind = "tema" )
type MathFormula ¶
type MathFormula struct { Source string `json:"source,omitempty" xml:",chardata"` // MathML Element Representing entire formula DocumentURL string `json:"durl,omitempty"` // document url (if any) LocalID string `json:"url" xml:"local_id,attr"` // local formula id XPath string `json:"xpath,omitempty"` // XPath from the formula -> query SubTerm string `json:"subterm,omitempty"` // MathML Element representing matching subterm Substitution map[string]string `json:"subst,omitempty"` // MathML Elements representing values for the subsituted terms }
MathFormula represents information about a single located math formula It supports JSON Marshal + Unmarshal (for reading it from mws results and sending it to the user) And XML Un-Marshelling (for reading it as part of raw harvest data)
func (*MathFormula) MathML ¶
func (formula *MathFormula) MathML() (*utils.MathML, error)
MathML returns a MathML object representing this MathFormula
func (*MathFormula) PopulateSubsitutions ¶
func (formula *MathFormula) PopulateSubsitutions(hit *Hit, res *Result) (err error)
PopulateSubsitutions populates the subsitutions field of this MathFormula, given a hit and a result
func (*MathFormula) RealMathID ¶
func (formula *MathFormula) RealMathID() string
RealMathID returns the math id used for this object in dictionaries
func (*MathFormula) SetURL ¶
func (formula *MathFormula) SetURL(url string)
SetURL sets the url of a MathInfo object
type QueryVariable ¶
type QueryVariable struct { Name string `json:"name"` // name of the variable XPath string `json:"xpath"` // xpath of the variable relative to the root }
QueryVariable represents a query variable
type Result ¶
type Result struct { Kind Kind `json:"kind"` // the kind of query this is a result to Took *time.Duration `json:"took,omitempty"` // how long the overall query took TookComponents map[string]*time.Duration `json:"stats,omitempty"` // how long each of the components took Total int64 `json:"total"` // the total number of results From int64 `json:"from"` // result number this page starts at Size int64 `json:"size"` // number of results returned Variables []*QueryVariable `json:"qvars,omitempty"` // the list of HitIDs []int64 `json:"ids,omitempty"` // the ids of the hits Hits []*Hit `json:"hits,omitempty"` // the current page of hits }
Result represents a Query Result which can be from either MathWebSearch, ElasticSearch or a combined TemaSearch Result too unmarshal
func (*Result) Normalize ¶
func (res *Result) Normalize()
Normalize normalizes a result so that it can be used reproducibly in tests
func (*Result) PopulateSubsitutions ¶
PopulateSubsitutions populates all substiutions within all hits of this result
func (*Result) UnmarshalElastic ¶
func (res *Result) UnmarshalElastic(page *elasticutils.ResultsPage) error
UnmarshalElastic un-marshals a response from elastic