Mercurial > moin > 1.9
changeset 4985:0603dfa4cc49
Groups2009: queryparser.TitleSearch.xapian_term was refactored. Xapian.Index.prefixMap attribute was removed.
author | Dmitrijs Milajevs <dimazest@gmail.com> |
---|---|
date | Fri, 07 Aug 2009 19:11:24 +0200 |
parents | bd1bbdb40a5f |
children | 1bc9dbb8d3f4 |
files | MoinMoin/search/Xapian.py MoinMoin/search/queryparser.py |
diffstat | 2 files changed, 13 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/search/Xapian.py Fri Aug 07 14:35:45 2009 +0200 +++ b/MoinMoin/search/Xapian.py Fri Aug 07 19:11:24 2009 +0200 @@ -226,10 +226,6 @@ class Index(BaseIndex): - # XXX This is needed for a query parser. Since xappy uses - # different terms, it is better to use xappy's query parser. - prefixMap = {'title': 'S'} - def __init__(self, request): self._check_version() BaseIndex.__init__(self, request)
--- a/MoinMoin/search/queryparser.py Fri Aug 07 14:35:45 2009 +0200 +++ b/MoinMoin/search/queryparser.py Fri Aug 07 19:11:24 2009 +0200 @@ -508,26 +508,25 @@ # all parsed wikiwords, ANDed queries = [] stemmed = [] - for t in terms: + for term in terms: if request.cfg.xapian_stemming: # stemmed OR not stemmed - tmp = [] - for w, s, pos in analyzer.tokenize(t, flat_stemming=False): - tmp.append(Query(Query.OP_OR, - [UnicodeQuery('%s%s' % - (Xapian.Index.prefixMap['title'], j), - 100) - for j in (w, s)])) + t = [] + for w, s, pos in analyzer.tokenize(term, flat_stemming=False): + # XXX weight for a query 100! + query_word = connection.query_field('title', w) + query_stemmed = connection.query_field('title', s) + + # XXX UnicodeQuery was used here! + t.append(Query(Query.OP_OR, [query_word, query_stemmed])) stemmed.append(s) - t = tmp else: # just not stemmed - t = [UnicodeQuery( - '%s%s' % (Xapian.Index.prefixMap['title'], w), - 100) - for w, pos in analyzer.tokenize(t)] + # XXX weight for a query 100! + # XXX UnicodeQuery was used here! + t = [connection.query_field('title', w) for w, pos in analyzer.tokenize(term)] - queries.append(Query(Query.OP_AND, t)) + queries.append(Query(Query.OP_OR, t)) if not self.case and stemmed: new_pat = ' '.join(stemmed)