Skip to content
This repository has been archived by the owner on Feb 20, 2022. It is now read-only.

Make works with cursor and method to set fields #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions solr.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ type DocumentCollection struct {
* Represents a Solr response
*/
type SelectResponse struct {
Results *DocumentCollection
Status int
QTime int
Results *DocumentCollection
NextCursorMark string
Status int
QTime int
// TODO: Debug info as well?
}

Expand All @@ -95,6 +96,8 @@ type URLParamMap map[string][]string
*/
type Query struct {
Params URLParamMap
Fields []string
CursorMark string
Rows int
Start int
Sort string
Expand All @@ -114,6 +117,14 @@ func (q *Query) String() string {
s = append(s, EncodeURLParamMap(&q.Params))
}

if len(q.Fields) > 0 && q.Fields[0] != "" {
s = append(s, fmt.Sprintf("fl=%s", strings.Join(q.Fields, ",")))
}

if q.CursorMark != "" {
s = append(s, fmt.Sprintf("cursorMark=%s", q.CursorMark))
}

if q.Rows != 0 {
s = append(s, fmt.Sprintf("rows=%d", q.Rows))
}
Expand Down Expand Up @@ -338,6 +349,10 @@ func BuildResponse(j *interface{}) (*SelectResponse, error) {
// begin Response creation
r := SelectResponse{}

if nextCursor, ok := (*j).(map[string]interface{})["nextCursorMark"]; ok {
r.NextCursorMark = nextCursor.(string)
}

// do status & qtime, if possible
r_header := (*j).(map[string]interface{})["responseHeader"].(map[string]interface{})
if r_header != nil {
Expand Down