1
0
mirror of https://github.com/djohnlewis/stackdump synced 2025-12-06 16:03:27 +00:00

Changed the default operator to AND properly this time. It has been changed in Solr configuration, instead of hacking the query string.

This commit is contained in:
Samuel Lai
2012-02-11 21:09:40 +11:00
parent 888d7d2e94
commit 6c58938d44
2 changed files with 3 additions and 5 deletions

View File

@@ -585,7 +585,7 @@
<defaultSearchField>text</defaultSearchField> <defaultSearchField>text</defaultSearchField>
<!-- SolrQueryParser configuration: defaultOperator="AND|OR" --> <!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
<solrQueryParser defaultOperator="OR"/> <solrQueryParser defaultOperator="AND"/>
<!-- copyField commands copy one field to another at the time a document <!-- copyField commands copy one field to another at the time a document
is added to the index. It's used either to index the same field differently, is added to the index. It's used either to index the same field differently,

View File

@@ -269,7 +269,7 @@ def view_question(site_key, question_id):
raise HTTPError(code=404, output='No site exists with the key %s.' % site_key) raise HTTPError(code=404, output='No site exists with the key %s.' % site_key)
# get the question referenced by this question id # get the question referenced by this question id
query = 'id:%s AND siteKey:%s' % (question_id, site_key) query = 'id:%s siteKey:%s' % (question_id, site_key)
results = solr_conn().search(query) results = solr_conn().search(query)
if len(results) == 0: if len(results) == 0:
raise HTTPError(code=404, output='No question exists with the id %s.' % question_id) raise HTTPError(code=404, output='No question exists with the id %s.' % question_id)
@@ -490,10 +490,8 @@ def perform_search(site_key=None):
# this query string contains any special bits we add that we don't want # this query string contains any special bits we add that we don't want
# the user to see. # the user to see.
int_query = query int_query = query
# force keywords to default to being ANDed, instead of ORed.
int_query = '{!lucene q.op=AND}' + query
if site_key: if site_key:
int_query += ' AND siteKey:%s' % site_key int_query += ' siteKey:%s' % site_key
# the page GET parameter is zero-based # the page GET parameter is zero-based
page = int(request.GET.get('p', 0)) page = int(request.GET.get('p', 0))