Commit d2202e89 authored by gergely-ujvari's avatar gergely-ujvari

Merge pull request #1862 from hypothesis/1796-add-any-field-handling-for-search-API

1796 add any field handling for search api
parents bd0b5822 766c8bc7
...@@ -43,6 +43,26 @@ class SearchFilter ...@@ -43,6 +43,26 @@ class SearchFilter
tokens tokens
# Turns string query into object, where the properties are the search terms
toObject: (searchtext) ->
obj = {}
addToObj = (key, data) ->
if obj[key]?
obj[key].push data
else
obj[key] = [data]
if searchtext
terms = @_tokenize(searchtext)
for term in terms
[filter, data] = term.split(':')
unless data
filter = 'any'
data = term
addToObj(filter, data)
obj
# This function will generate the facets from the search-text input # This function will generate the facets from the search-text input
# It'll first tokenize it and then sorts them into facet lists # It'll first tokenize it and then sorts them into facet lists
# The output will be a dict with the following structure: # The output will be a dict with the following structure:
......
...@@ -20,7 +20,8 @@ class StreamSearchController ...@@ -20,7 +20,8 @@ class StreamSearchController
queryparser.populateFilter streamfilter, terms queryparser.populateFilter streamfilter, terms
# Perform the search # Perform the search
query = angular.extend limit: 10, $scope.search.query searchParams = searchfilter.toObject $scope.search.query
query = angular.extend limit: 10, searchParams
store.SearchResource.get query, ({rows}) -> store.SearchResource.get query, ({rows}) ->
annotator.loadAnnotations(rows) annotator.loadAnnotations(rows)
......
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