diff --git a/pkg/search/expr_test.go b/pkg/search/expr_test.go index 8c0196dbf..91c0fc207 100644 --- a/pkg/search/expr_test.go +++ b/pkg/search/expr_test.go @@ -61,6 +61,22 @@ var attrgorunC = &Constraint{ }, } +var hasLocationC = orConst(&Constraint{ + Permanode: &PermanodeConstraint{ + Attr: "camliContent", + ValueInSet: &Constraint{ + File: &FileConstraint{ + IsImage: true, + Location: &LocationConstraint{Any: true}, + }, + }, + }, +}, &Constraint{ + Permanode: &PermanodeConstraint{ + Location: &LocationConstraint{Any: true}, + }, +}) + var parseExpressionTests = []struct { name string in string @@ -263,17 +279,7 @@ var parseExpressionTests = []struct { { in: "has:location", want: &SearchQuery{ - Constraint: andConst(skiphiddenC, &Constraint{ - Permanode: &PermanodeConstraint{ - Attr: "camliContent", - ValueInSet: &Constraint{ - File: &FileConstraint{ - IsImage: true, - Location: &LocationConstraint{Any: true}, - }, - }, - }, - }), + Constraint: andConst(skiphiddenC, hasLocationC), }, }, @@ -589,20 +595,8 @@ var parseExpTests = []parserTestCase{ }, { - in: "has:location", - want: &Constraint{ - Permanode: &PermanodeConstraint{ - Attr: "camliContent", - ValueInSet: &Constraint{ - File: &FileConstraint{ - IsImage: true, - Location: &LocationConstraint{ - Any: true, - }, - }, - }, - }, - }, + in: "has:location", + want: hasLocationC, }, { diff --git a/pkg/search/predicate.go b/pkg/search/predicate.go index d4abd3e1b..eafa99809 100644 --- a/pkg/search/predicate.go +++ b/pkg/search/predicate.go @@ -485,7 +485,7 @@ func newLocation() keyword { } func (l location) Description() string { - return "uses the EXIF GPS fields to match images having a location near\n" + + return "matches images and permanodes having a location near\n" + "the specified location. Locations are resolved using\n" + "maps.googleapis.com. For example: loc:\"new york, new york\" " } @@ -535,18 +535,25 @@ func newHasLocation() keyword { } func (h hasLocation) Description() string { - return "image has a location (GPSLatitude and GPSLongitude can be\n" + + return "matches images and permanodes that have a location (GPSLatitude and GPSLongitude can be\n" + "retrieved from the image's EXIF tags)." } func (h hasLocation) Predicate(ctx *context.Context, args []string) (*Constraint, error) { - c := permOfFile(&FileConstraint{ + fileLoc := permOfFile(&FileConstraint{ IsImage: true, Location: &LocationConstraint{ Any: true, }, }) - return c, nil + permLoc := &Constraint{ + Permanode: &PermanodeConstraint{ + Location: &LocationConstraint{ + Any: true, + }, + }, + } + return orConst(fileLoc, permLoc), nil } // Helpers diff --git a/pkg/search/predicate_test.go b/pkg/search/predicate_test.go index dc483113d..8ed2893a0 100644 --- a/pkg/search/predicate_test.go +++ b/pkg/search/predicate_test.go @@ -493,17 +493,7 @@ var keywordTests = []keywordTestcase{ { object: newHasLocation(), - want: &Constraint{ - Permanode: &PermanodeConstraint{ - Attr: "camliContent", - ValueInSet: &Constraint{ - File: &FileConstraint{ - IsImage: true, - Location: &LocationConstraint{Any: true}, - }, - }, - }, - }, + want: hasLocationC, }, }