~jcsackett/charmworld/bac-tag-constraints

« back to all changes in this revision

Viewing changes to charmworld/search.py

  • Committer: Tarmac
  • Author(s): Aaron Bentley
  • Date: 2013-08-08 19:46:31 UTC
  • mfrom: (338.2.2 separate-text-queries)
  • Revision ID: tarmac-20130808194631-pwx2gpgqt6a29n8y
[r=bac][bug=][author=abentley] Separate bundle text fields from charm text fields in search.

Show diffs side-by-side

added added

removed removed

Lines of Context:
258
258
                  for field, boost in free_text_fields.items()]
259
259
        fields.extend(exact_fields)
260
260
        if text != '':
261
 
            dsl = {
262
 
                'query_string': {
263
 
                    'query': text,
264
 
                    'fields': fields,
265
 
                }
266
 
            }
 
261
            charm_dsl = {'filtered': {
 
262
                'query': {
 
263
                    'query_string': {
 
264
                        'query': text,
 
265
                        'fields': fields,
 
266
                    }},
 
267
                'filter': {'type': {'value': CHARM}}
 
268
            }}
 
269
            bundle_dsl = {'filtered': {
 
270
                'query': {
 
271
                    'query_string': {
 
272
                        'query': text,
 
273
                        'fields': fields,
 
274
                    }},
 
275
                'filter': {'type': {'value': BUNDLE}}
 
276
            }}
 
277
            # Union the bundle_dsl and charm_dsl results
 
278
            dsl = {'bool': {'should': [bundle_dsl, charm_dsl]}}
267
279
        else:
268
280
            dsl = {'match_all': {}}
269
281
        return dsl