From d46e7d8f3a619eee96a40d2d730fb0639f1c0f1d Mon Sep 17 00:00:00 2001 From: Guilherme Santos Date: Fri, 30 Oct 2015 17:00:48 -0200 Subject: [PATCH] Make works with cursor and method to set fields --- solr.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/solr.go b/solr.go index 09664e9..d5536f8 100644 --- a/solr.go +++ b/solr.go @@ -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? } @@ -95,6 +96,8 @@ type URLParamMap map[string][]string */ type Query struct { Params URLParamMap + Fields []string + CursorMark string Rows int Start int Sort string @@ -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)) } @@ -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 {