Documentation
¶
Index ¶
- type CollectionsAPIResponse
- type FacetField
- type FieldTypesResponse
- type FilterQuery
- type LiveNodes
- type SolrClient
- func (sc *SolrClient) Commit(collectionName string) error
- func (sc *SolrClient) Connect(zksString string) error
- func (sc *SolrClient) CreateCollection(name string, numShards int, replicationFactor int, timeout time.Duration) error
- func (sc *SolrClient) DeleteByQuery(collectionName string, query string) error
- func (sc *SolrClient) DeleteCollection(name string) error
- func (sc *SolrClient) FieldTypes(collection string) (*FieldTypesResponse, error)
- func (sc *SolrClient) LBNodeAddress() string
- func (sc *SolrClient) LiveSolrNodes() (*LiveNodes, error)
- func (sc *SolrClient) PostDocs(docs *SolrDocumentCollection, targetCollection string) error
- func (sc *SolrClient) PostStructs(data []interface{}, targetCollection string) error
- func (sc *SolrClient) Query(collection string, reqHandler string, params *SolrParams, ...) (*SolrSearchResponse, error)
- type SolrCollectionExistsError
- type SolrDocument
- func (sd *SolrDocument) Exists(name string) bool
- func (sd *SolrDocument) GetField(name string) ([]string, error)
- func (sd *SolrDocument) ID() string
- func (sd *SolrDocument) SetField(name string, values []string)
- func (sd *SolrDocument) SetID(id string)
- func (sd *SolrDocument) SolrJSON() (string, error)
- type SolrDocumentCollection
- type SolrFacetField
- type SolrParams
- type SolrSearchDocument
- func (sd SolrSearchDocument) Float64(fieldName string) (float64, error)
- func (sd SolrSearchDocument) HasField(fieldName string) bool
- func (sd SolrSearchDocument) Int64(fieldName string) (int64, error)
- func (sd SolrSearchDocument) Slice(fieldName string) ([]interface{}, error)
- func (sd SolrSearchDocument) String(fieldName string) string
- func (sd SolrSearchDocument) StringSlice(fieldName string) ([]string, error)
- type SolrSearchResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CollectionsAPIResponse ¶
type CollectionsAPIResponse struct {
ResponseHeader struct {
Status int `json:"status"`
QTime int `json:"QTime"`
} `json:"responseHeader"`
Success struct {
One921681668983Solr struct {
ResponseHeader struct {
Status int `json:"status"`
QTime int `json:"QTime"`
} `json:"responseHeader"`
Core string `json:"core"`
} `json:"192.168.1.66:8983_solr"`
One921681667574Solr struct {
ResponseHeader struct {
Status int `json:"status"`
QTime int `json:"QTime"`
} `json:"responseHeader"`
Core string `json:"core"`
} `json:"192.168.1.66:7574_solr"`
} `json:"success"`
Warning string `json:"warning"`
OperationCreateCausedException string `json:"Operation create caused exception:"`
Exception struct {
Msg string `json:"msg"`
RspCode int `json:"rspCode"`
} `json:"exception"`
Error struct {
Metadata []string `json:"metadata"`
Msg string `json:"msg"`
Code int `json:"code"`
} `json:"error"`
}
CollectionsAPIResponse solr collections api response struct
type FacetField ¶
type FacetField []string
func (*FacetField) UnmarshalJSON ¶
func (ff *FacetField) UnmarshalJSON(data []byte) error
UnmarshalJSON an override because the Solr response can return a single value or a slice depending on how many facet fields are in the request. This gurantees that the FacetField part of the response serializes to our static type (a string slice)
type FieldTypesResponse ¶
type FieldTypesResponse struct {
ResponseHeader struct {
Status int `json:"status"`
QTime int `json:"QTime"`
} `json:"responseHeader"`
FieldTypes []struct {
Name string `json:"name"`
Class string `json:"class"`
IndexAnalyzer struct {
Tokenizer struct {
Class string `json:"class"`
} `json:"tokenizer"`
} `json:"indexAnalyzer,omitempty"`
QueryAnalyzer struct {
Tokenizer struct {
Class string `json:"class"`
Delimiter string `json:"delimiter"`
} `json:"tokenizer"`
} `json:"queryAnalyzer,omitempty"`
SortMissingLast bool `json:"sortMissingLast,omitempty"`
MultiValued bool `json:"multiValued,omitempty"`
Indexed bool `json:"indexed,omitempty"`
Stored bool `json:"stored,omitempty"`
Analyzer struct {
Tokenizer struct {
Class string `json:"class"`
} `json:"tokenizer"`
Filters []struct {
Class string `json:"class"`
Encoder string `json:"encoder"`
} `json:"filters"`
} `json:"analyzer,omitempty"`
DocValues bool `json:"docValues,omitempty"`
Geo string `json:"geo,omitempty"`
MaxDistErr string `json:"maxDistErr,omitempty"`
DistErrPct string `json:"distErrPct,omitempty"`
DistanceUnits string `json:"distanceUnits,omitempty"`
PositionIncrementGap string `json:"positionIncrementGap,omitempty"`
SubFieldSuffix string `json:"subFieldSuffix,omitempty"`
Dimension string `json:"dimension,omitempty"`
AutoGeneratePhraseQueries string `json:"autoGeneratePhraseQueries,omitempty"`
} `json:"fieldTypes"`
}
type FilterQuery ¶
type FilterQuery []string
func (*FilterQuery) UnmarshalJSON ¶
func (ff *FilterQuery) UnmarshalJSON(data []byte) error
type LiveNodes ¶
LiveNodes struct to hold slice of live nodes and when the last time live nodes were updated
type SolrClient ¶
SolrClient Solr Client struct
func NewDirectSolrClient ¶
func NewDirectSolrClient(solrUrl string) (*SolrClient, error)
func NewSolrClient ¶
func NewSolrClient(zksString string) (*SolrClient, error)
NewSolrClient returns a new instance of a Solr Client
func (*SolrClient) Commit ¶
func (sc *SolrClient) Commit(collectionName string) error
Commit executes a Solr commit command
func (*SolrClient) Connect ¶
func (sc *SolrClient) Connect(zksString string) error
Connect Connects the SolrClient instance
func (*SolrClient) CreateCollection ¶
func (sc *SolrClient) CreateCollection(name string, numShards int, replicationFactor int, timeout time.Duration) error
CreateCollection creates a Solr collection
func (*SolrClient) DeleteByQuery ¶
func (sc *SolrClient) DeleteByQuery(collectionName string, query string) error
DeleteByQuery deletes documents matching a Solr query
func (*SolrClient) DeleteCollection ¶
func (sc *SolrClient) DeleteCollection(name string) error
DeleteCollection deletes a Solr collection
func (*SolrClient) FieldTypes ¶
func (sc *SolrClient) FieldTypes(collection string) (*FieldTypesResponse, error)
func (*SolrClient) LBNodeAddress ¶
func (sc *SolrClient) LBNodeAddress() string
LBNodeAddress Returns a node address using simple round robin LB of available nodes
func (*SolrClient) LiveSolrNodes ¶
func (sc *SolrClient) LiveSolrNodes() (*LiveNodes, error)
LiveSolrNodes returns a slice of urls to live Solr nodes
func (*SolrClient) PostDocs ¶
func (sc *SolrClient) PostDocs(docs *SolrDocumentCollection, targetCollection string) error
PostDocs indexes a SolrDocumentCollection
func (*SolrClient) PostStructs ¶
func (sc *SolrClient) PostStructs(data []interface{}, targetCollection string) error
func (*SolrClient) Query ¶
func (sc *SolrClient) Query(collection string, reqHandler string, params *SolrParams, timeout time.Duration) (*SolrSearchResponse, error)
Search executes a Solr search
type SolrCollectionExistsError ¶
type SolrCollectionExistsError struct {
// contains filtered or unexported fields
}
func (*SolrCollectionExistsError) Error ¶
func (e *SolrCollectionExistsError) Error() string
type SolrDocument ¶
type SolrDocument struct {
// contains filtered or unexported fields
}
SolrDocument struct the holds fields and provides methods for manipulating them
func NewSolrDocument ¶
func NewSolrDocument(id string) SolrDocument
NewSolrDocument creates a new instance of a SolrDocument
func (*SolrDocument) Exists ¶
func (sd *SolrDocument) Exists(name string) bool
Exists returns a bool. True = the field exists. False = the field does not exist.
func (*SolrDocument) GetField ¶
func (sd *SolrDocument) GetField(name string) ([]string, error)
GetField returns a field from the document if it exists
func (*SolrDocument) SetField ¶
func (sd *SolrDocument) SetField(name string, values []string)
SetField sets the value for a field in the SolrDocument
func (*SolrDocument) SetID ¶
func (sd *SolrDocument) SetID(id string)
SetID sets the Id of the document
func (*SolrDocument) SolrJSON ¶
func (sd *SolrDocument) SolrJSON() (string, error)
SolrJSON returns the json representation of a solr document for indexing
type SolrDocumentCollection ¶
type SolrDocumentCollection struct {
// contains filtered or unexported fields
}
SolrDocumentCollection holds a collection of SolrDocuments
func NewSolrDocumentCollection ¶
func NewSolrDocumentCollection() SolrDocumentCollection
NewSolrDocumentCollection returns a new instance of a SolrDocumentCollection
func (*SolrDocumentCollection) AddDoc ¶
func (sdc *SolrDocumentCollection) AddDoc(doc SolrDocument) error
AddDoc adds a document to the collection
func (*SolrDocumentCollection) DeleteDoc ¶
func (sdc *SolrDocumentCollection) DeleteDoc(id string)
DeleteDoc removes a doc by id
func (*SolrDocumentCollection) GetDoc ¶
func (sdc *SolrDocumentCollection) GetDoc(id string) SolrDocument
GetDoc returns a doc by id
func (*SolrDocumentCollection) NumDocs ¶
func (sdc *SolrDocumentCollection) NumDocs() int
NumDocs returns the number of docs in the collection
func (*SolrDocumentCollection) SolrJSON ¶
func (sdc *SolrDocumentCollection) SolrJSON() (string, error)
SolrJSON returns a json string representation of the doc collection ready for Solr
type SolrFacetField ¶
type SolrFacetField struct {
Name string `json:"name"`
Type string `json:"type"`
Value int `json:"value"`
}
SolrFacetField holds data for facet fields from a Solr response. NOTE: you must use &json.nl=arrntv on your Solr queries for this to work
type SolrParams ¶
type SolrParams struct {
Q string `json:"q" url:"q,omitempty"`
DefType string `json:"defType" url:"defType,omitempty"`
FacetField FacetField `json:"facet.field" url:"facet.field,omitempty"`
JSONNl string `json:"json.nl" url:"json.nl,omitempty"`
Qf string `json:"qf" url:"qf,omitempty"`
Fl string `json:"fl" url:"fl,omitempty"`
Rows string `json:"rows" url:"rows,omitempty"`
Facet string `json:"facet" url:"facet,omitempty"`
Bq string `json:"bq" url:"bq,omitempty"`
Fq FilterQuery `json:"fq" url:"fq,omitempty"`
Sort string `json:"sort" url:"sort,omitempty"`
Start string `json:"start" url:"start,omitempty"`
}
SolrParams hold information for a Solr request
type SolrSearchDocument ¶
type SolrSearchDocument map[string]interface{}
SolrSearchDocument holds fields of a returned document and provides helper methods for accessing values
func (SolrSearchDocument) Float64 ¶
func (sd SolrSearchDocument) Float64(fieldName string) (float64, error)
Float64 returns a float64 field
func (SolrSearchDocument) HasField ¶
func (sd SolrSearchDocument) HasField(fieldName string) bool
HasField returns true if the document has a specified field
func (SolrSearchDocument) Int64 ¶
func (sd SolrSearchDocument) Int64(fieldName string) (int64, error)
Int64 returns a int64 field or casts a float64 field to an int
func (SolrSearchDocument) Slice ¶
func (sd SolrSearchDocument) Slice(fieldName string) ([]interface{}, error)
Slice returns a slice (array) field
func (SolrSearchDocument) String ¶
func (sd SolrSearchDocument) String(fieldName string) string
String returns a string representation of a field
func (SolrSearchDocument) StringSlice ¶
func (sd SolrSearchDocument) StringSlice(fieldName string) ([]string, error)
StringSlice returns a string slice (array) field
type SolrSearchResponse ¶
type SolrSearchResponse struct {
ResponseHeader struct {
ZkConnected bool `json:"zkConnected"`
Status int `json:"status"`
QTime int `json:"QTime"`
Params SolrParams `json:"params"`
} `json:"responseHeader"`
Response struct {
NumFound int `json:"numFound"`
Start int `json:"start"`
MaxScore float64 `json:"maxScore"`
Docs []SolrSearchDocument `json:"docs"`
} `json:"response"`
FacetCounts struct {
FacetQueries struct {
} `json:"facet_queries"`
FacetFields map[string][]SolrFacetField `json:"facet_fields"`
FacetRanges struct {
} `json:"facet_ranges"`
FacetIntervals struct {
} `json:"facet_intervals"`
FacetHeatmaps struct {
} `json:"facet_heatmaps"`
} `json:"facet_counts"`
}
SolrSearchResponse holds information about a Solr search response