[IIAB] autocompletion search
Braddock
braddock at braddock.com
Fri Mar 15 15:37:45 PDT 2013
Hi Joel,
The Gutenberg search site looks great!
Does it work on smartphones? (haven't tried it yet)
I think you can greatly enhance your autocomplete and search result
rankings by using the pgterms:downloads counter in the catalog as a
popularity measure. By eyeball, it looks like a pretty reliable indicator.
Obviously the autocomplete needs to be done server-side. I have
server-side autocomplete jqueryUI/Flask/python code snippets below if
they are helpful. Basically you just return a JSON list. See the
jquery UI autocomplete demo for the javascript side - it isn't hard to
set up.
thanks,
braddock
@blueprint.route('wikititles_autocomplete')
def wikititles_autocomplete_view():
partial = request.args.get('term')
p = wikititles_mongo.autocomplete(database(), partial)
j = json_dumps(list(p))
return Response(j, mimetype='application/json')
[...snip...]
def autocomplete(db, prefix):
upperPrefix = prefix.upper()
regex = get_prefix_regex(upperPrefix)
matching = db.wikititles.find(
{'name_in_upper_case': regex}
).sort(
[('reverse_links', -1)]
)
return (title['name'] for title in matching)
On 03/09/2013 03:25 PM, Joel Steres wrote:
> Based on suggestions at HAK I added prototype of a search autocomplete
> feature. To offload the server I pass all the possible matches to the
> client at once rather than interactively getting autocomplete
> suggestions from the server on each keypress. The result is it is too
> big/slow and only matches single strings. Still, would someone please
> test it and tell me if it is worth pursuing. (Note may require
> patience. When I loaded it from zhen across several network hops it
> took 11 seconds before it was loaded. Not sure why especially when
> the response code was 304, not modified.)
>
> Autocomplete is only attached to the search box at
> http://127.0.0.1:25000/iiab/books/
More information about the IIAB
mailing list