Commit 0a06d695 authored by Ujvari Gergely's avatar Ujvari Gergely

Separate facet parameters for streamsearch and bugfix

- The old ?query= has been decoupled to separate facet parameters
- Bugfix: If the same facet was given twice it only used the last one. Now it is fixed.
parent 83e1f6cb
...@@ -28,6 +28,7 @@ class SearchHelper ...@@ -28,6 +28,7 @@ class SearchHelper
for searchItem in models for searchItem in models
category = searchItem.attributes.category category = searchItem.attributes.category
value = searchItem.attributes.value value = searchItem.attributes.value
if category is 'limit' then limit = value if category is 'limit' then limit = value
else else
if category is 'text' if category is 'text'
...@@ -37,7 +38,7 @@ class SearchHelper ...@@ -37,7 +38,7 @@ class SearchHelper
catlist.push val for val in value.split ' ' catlist.push val for val in value.split ' '
categories[category] = catlist categories[category] = catlist
else else
if category in categories then categories[category].push value if category of categories then categories[category].push value
else categories[category] = [value] else categories[category] = [value]
filter.setPastDataHits(limit) filter.setPastDataHits(limit)
...@@ -80,9 +81,11 @@ class SearchHelper ...@@ -80,9 +81,11 @@ class SearchHelper
value_part = if rule.formatter then rule.formatter val else val value_part = if rule.formatter then rule.formatter val else val
filter.addClause mapped_field, oper_part, value_part, case_sensitive filter.addClause mapped_field, oper_part, value_part, case_sensitive
filter.getFilter() categories['limit'] = [limit]
[filter.getFilter(), categories]
class StreamSearch class StreamSearch
facets: ['text','tags', 'uri', 'quote','created','user','limit']
rules: rules:
user: user:
formatter: (user) -> formatter: (user) ->
...@@ -157,8 +160,12 @@ class StreamSearch ...@@ -157,8 +160,12 @@ class StreamSearch
# Read search params # Read search params
search_query = '' search_query = ''
params = $location.search() params = $location.search()
if params.query? for param, values of params
search_query = params.query # Ignore non facet parameters
if param in @facets
unless values instanceof Array then values = [values]
for value in values
search_query += param + ': "' + value + '" '
# Initialize Visual search # Initialize Visual search
@search = VS.init @search = VS.init
...@@ -172,13 +179,12 @@ class StreamSearch ...@@ -172,13 +179,12 @@ class StreamSearch
.setMatchPolicyIncludeAll() .setMatchPolicyIncludeAll()
.noClauses() .noClauses()
filter = new SearchHelper().populateFilter filter, searchCollection.models, @rules [filter, $scope.categories] =
console.log filter new SearchHelper().populateFilter filter, searchCollection.models, @rules
$scope.initStream filter $scope.initStream filter
# Update the parameters # Update the parameters
$location.search $location.search $scope.categories
'query' : query
facetMatches: (callback) => facetMatches: (callback) =>
# Created and limit should be singleton. # Created and limit should be singleton.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment