MCPcopy
hub / github.com/perkeep/perkeep / plannedQuery

Method plannedQuery

pkg/search/query.go:141–166  ·  view source on GitHub ↗

exprQuery optionally specifies the *SearchQuery prototype that was generated by parsing the search expression

(expr *SearchQuery)

Source from the content-addressed store, hash-verified

139// exprQuery optionally specifies the *SearchQuery prototype that was generated
140// by parsing the search expression
141func (q *SearchQuery) plannedQuery(expr *SearchQuery) *SearchQuery {
142 pq := new(SearchQuery)
143 *pq = *q
144 if expr != nil {
145 pq.Constraint = expr.Constraint
146 if expr.Sort != 0 {
147 pq.Sort = expr.Sort
148 }
149 if expr.Limit != 0 {
150 pq.Limit = expr.Limit
151 }
152 }
153 if pq.Sort == UnspecifiedSort {
154 if pq.Constraint.onlyMatchesPermanode() {
155 pq.Sort = CreatedDesc
156 }
157 }
158 if pq.Limit == 0 {
159 pq.Limit = 200 // arbitrary
160 }
161 if err := pq.addContinueConstraint(); err != nil {
162 log.Printf("Ignoring continue token: %v", err)
163 }
164 pq.Constraint = optimizePlan(pq.Constraint)
165 return pq
166}
167
168// For permanodes, the continue token is (currently!)
169// of form "pn:nnnnnnn:sha1-xxxxx" where "pn" is a

Callers 2

ExportPlannedQueryMethod · 0.95
QueryMethod · 0.80

Calls 4

optimizePlanFunction · 0.85
onlyMatchesPermanodeMethod · 0.80
addContinueConstraintMethod · 0.80
PrintfMethod · 0.80

Tested by 1

ExportPlannedQueryMethod · 0.76