From 34b70f7df8fa9e7ca82798994b6ce5c62b7defb0 Mon Sep 17 00:00:00 2001 From: Adam Creeger Date: Tue, 9 Aug 2011 08:19:06 -0700 Subject: [PATCH] Adding basic (non-geo) location search to ES search functionality. --- .../controllers/org/cafeCentro/EventController.groovy | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grails-app/controllers/org/cafeCentro/EventController.groovy b/grails-app/controllers/org/cafeCentro/EventController.groovy index 56165fb..6e6f06b 100644 --- a/grails-app/controllers/org/cafeCentro/EventController.groovy +++ b/grails-app/controllers/org/cafeCentro/EventController.groovy @@ -31,7 +31,11 @@ class EventController { } private def performSearchUsingElasticSearch(q,location,offset, max) { - Map searchResults = Event.search(q.encodeAsElasticSearchQuery(),[offset:offset,max:max,sort:"date"]) + def esQuery = q ? q.encodeAsElasticSearchQuery() : "" + def locationQueryString = location ? " venue.city:(${location.encodeAsElasticSearchQuery()})" : "" + esQuery += locationQueryString + + Map searchResults = Event.search(esQuery,[offset:offset,max:max,sort:"date"]) return [results:searchResults.searchResults, totalCount:searchResults.total] }