~jcsackett/charmworld/bac-tag-constraints

« back to all changes in this revision

Viewing changes to charmworld/views/search.py

  • Committer: Aaron Bentley
  • Date: 2013-03-28 16:55:07 UTC
  • mto: This revision was merged to the branch mainline in revision 182.
  • Revision ID: aaron@canonical.com-20130328165507-yoiwb2pdby5tz9n8
Remove all mention of Xapian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
from pyramid.httpexceptions import HTTPFound
7
7
from webob import Response
8
8
 
9
 
from charmworld.jobs.config import CHARM_INDEX_DIR
10
9
from charmworld.search import ElasticSearchClient
11
 
from charmworld.views import SEARCH_FIELDS
12
10
from charmworld.views.helpers import result_sorter
13
 
from charmworld.utils import (
14
 
    get_ini,
15
 
    Timer,
16
 
)
17
 
 
18
 
 
19
 
def do_xappy_search(terms, allow_all_fields=False):
20
 
    import xappy
21
 
    searcher = xappy.SearchConnection(CHARM_INDEX_DIR)
22
 
    if allow_all_fields:
23
 
        deny = []
24
 
    else:
25
 
        deny = ['relations', 'config', 'changes']
26
 
    query = searcher.query_parse(
27
 
        terms,
28
 
        allow=SEARCH_FIELDS,
29
 
        allow_wildcards=True,
30
 
        default_deny=deny)
31
 
 
32
 
    with Timer() as timer:
33
 
        results = query.search(0, 30)
34
 
    search_time = u"%.5f" % timer.duration()
35
 
    return {"results": results,
36
 
            "search_time": search_time,
37
 
            "charm_total": searcher.get_doccount()}
 
11
from charmworld.utils import get_ini
38
12
 
39
13
 
40
14
def do_search(terms, allow_all_fields=False):