当前位置: 首页>>代码示例>>Python>>正文


Python EMPTY_QUERY.get方法代码示例

本文整理汇总了Python中search.conf.EMPTY_QUERY.get方法的典型用法代码示例。如果您正苦于以下问题:Python EMPTY_QUERY.get方法的具体用法?Python EMPTY_QUERY.get怎么用?Python EMPTY_QUERY.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在search.conf.EMPTY_QUERY的用法示例。


在下文中一共展示了EMPTY_QUERY.get方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: query

# 需要导入模块: from search.conf import EMPTY_QUERY [as 别名]
# 或者: from search.conf.EMPTY_QUERY import get [as 别名]
  def query(self, solr_query, hue_core):
    try:
      params = self._get_params() + (
          ('q', solr_query['q'] or EMPTY_QUERY.get()),
          ('wt', 'json'),
          ('rows', solr_query['rows']),
          ('start', solr_query['start']),
      )

      params += hue_core.get_query(solr_query)

      fqs = solr_query['fq'].split('|')
      for fq in fqs:
        if fq:
          params += (('fq', fq),)

      response = self._root.get('%(collection)s/select' % solr_query, params)

      if type(response) != dict:
        # Got 'plain/text' mimetype instead of 'application/json'
        try:
          response = json.loads(response)
        except ValueError, e:
          # Got some null bytes in the response
          LOG.error('%s: %s' % (unicode(e), repr(response)))
          response = json.loads(response.replace('\x00', ''))
      return response
开发者ID:devinshields,项目名称:hue,代码行数:29,代码来源:api.py

示例2: stats

# 需要导入模块: from search.conf import EMPTY_QUERY [as 别名]
# 或者: from search.conf.EMPTY_QUERY import get [as 别名]
 def stats(self, core, fields):
   try:
     params = (
         ('q', EMPTY_QUERY.get()),
         ('wt', 'json'),
         ('rows', 0),
         ('stats', 'true'),
     )
     params += tuple([('stats.field', field) for field in fields])
     response = self._root.get('%(core)s/select' % {'core': core}, params=params)
     return self._get_json(response)
   except RestException, e:
     raise PopupException(e, title=_('Error while accessing Solr'))
开发者ID:findhy,项目名称:hue,代码行数:15,代码来源:api.py

示例3: stats

# 需要导入模块: from search.conf import EMPTY_QUERY [as 别名]
# 或者: from search.conf.EMPTY_QUERY import get [as 别名]
  def stats(self, core, fields, query=None, facet=''):
    try:
      params = self._get_params() + (
          ('q', self._get_q(query) if query is not None else EMPTY_QUERY.get()),
          ('wt', 'json'),
          ('rows', 0),
          ('stats', 'true'),
      )
      if facet:
        params += (('stats.facet', facet),)

      params += tuple([('stats.field', field) for field in fields])
      response = self._root.get('%(core)s/select' % {'core': core}, params=params)
      return self._get_json(response)
    except RestException, e:
      raise PopupException(e, title=_('Error while accessing Solr'))
开发者ID:prashant-bhalesain,项目名称:hue,代码行数:18,代码来源:api.py

示例4: query

# 需要导入模块: from search.conf import EMPTY_QUERY [as 别名]
# 或者: from search.conf.EMPTY_QUERY import get [as 别名]
  def query(self, solr_query, hue_core):
    try:
      params = (
          ('q', solr_query['q'] or EMPTY_QUERY.get()),
          ('wt', 'json'),
          ('rows', solr_query['rows']),
          ('start', solr_query['start']),
      )

      params += hue_core.get_query()

      fqs = solr_query['fq'].split('|')
      for fq in fqs:
        if fq:
          params += (('fq', fq),)

      response = self._root.get('%(collection)s/select' % solr_query, params)
      return json.loads(response)
    except RestException, e:
      raise PopupException('Error while accessing Solr: %s' % e)
开发者ID:MarvinWang,项目名称:hue,代码行数:22,代码来源:api.py

示例5: stats

# 需要导入模块: from search.conf import EMPTY_QUERY [as 别名]
# 或者: from search.conf.EMPTY_QUERY import get [as 别名]
    def stats(self, core, fields, query=None, facet=""):
        try:
            params = self._get_params() + (
                ("q", self._get_q(query) if query is not None else EMPTY_QUERY.get()),
                ("wt", "json"),
                ("rows", 0),
                ("stats", "true"),
            )

            if query is not None:
                params += self._get_fq(None, query)

            if facet:
                params += (("stats.facet", facet),)

            params += tuple([("stats.field", field) for field in fields])
            response = self._root.get("%(core)s/select" % {"core": core}, params=params)

            return self._get_json(response)
        except RestException, e:
            raise PopupException(e, title=_("Error while accessing Solr"))
开发者ID:fangxingli,项目名称:hue,代码行数:23,代码来源:api.py

示例6: query

# 需要导入模块: from search.conf import EMPTY_QUERY [as 别名]
# 或者: from search.conf.EMPTY_QUERY import get [as 别名]
  def query(self, solr_query, hue_core):
    try:
      params = self._get_params() + (
          ('q', solr_query['q'] or EMPTY_QUERY.get()),
          ('wt', 'json'),
          ('rows', solr_query['rows']),
          ('start', solr_query['start']),
      )

      params += hue_core.get_query(solr_query)

      fqs = solr_query['fq'].split('|')
      for fq in fqs:
        if fq:
          params += (('fq', urllib.unquote(utf_quoter(fq))),)

      response = self._root.get('%(collection)s/select' % solr_query, params)

      return self._get_json(response)
    except RestException, e:
      raise PopupException(e, title=_('Error while accessing Solr'))
开发者ID:2013Commons,项目名称:hue,代码行数:23,代码来源:api.py

示例7: query

# 需要导入模块: from search.conf import EMPTY_QUERY [as 别名]
# 或者: from search.conf.EMPTY_QUERY import get [as 别名]
    def query(self, solr_query, hue_core):
        try:
            params = (
                ("q", solr_query["q"] or EMPTY_QUERY.get()),
                ("wt", "json"),
                ("rows", solr_query["rows"]),
                ("start", solr_query["start"]),
            )

            params += hue_core.get_query(solr_query)

            fqs = solr_query["fq"].split("|")
            for fq in fqs:
                if fq:
                    params += (("fq", fq),)

            response = self._root.get("%(collection)s/select" % solr_query, params)

            if type(response) != dict:
                # Got 'plain/text' mimetype instead of 'application/json'
                response = json.loads(response)
            return response
        except RestException, e:
            raise PopupException("Error while accessing Solr: %s" % e)
开发者ID:2013Commons,项目名称:HUE-SHARK,代码行数:26,代码来源:api.py

示例8: query

# 需要导入模块: from search.conf import EMPTY_QUERY [as 别名]
# 或者: from search.conf.EMPTY_QUERY import get [as 别名]
  def query(self, solr_query, hue_core):
    try:
      params = self._get_params() + (
          ('q', solr_query['q'] or EMPTY_QUERY.get()),
          ('wt', 'json'),
          ('rows', solr_query['rows']),
          ('start', solr_query['start']),
      )

      params += hue_core.get_query(solr_query)

      fqs = solr_query['fq'].split('|')
      for fq in fqs:
        if fq:
          params += (('fq', fq),)

      response = self._root.get('%(collection)s/select' % solr_query, params)

      if type(response) != dict:
        # Got 'plain/text' mimetype instead of 'application/json'
        response = json.loads(response)
      return response
    except RestException, e:
      raise PopupException('Error while accessing Solr: %s' % e)
开发者ID:branchp,项目名称:hue,代码行数:26,代码来源:api.py

示例9: query

# 需要导入模块: from search.conf import EMPTY_QUERY [as 别名]
# 或者: from search.conf.EMPTY_QUERY import get [as 别名]
  def query(self, collection, query):
    solr_query = {}

    solr_query['collection'] = collection['name']

    if query.get('download'):
      solr_query['rows'] = 1000
      solr_query['start'] = 0
    else:
      solr_query['rows'] = int(collection['template']['rows'] or 10)
      solr_query['start'] = int(query['start'])

    solr_query['rows'] = min(solr_query['rows'], 1000)
    solr_query['start'] = min(solr_query['start'], 10000)

    q_template = '(%s)' if len(query['qs']) >= 2 else '%s'

    params = self._get_params() + (
        ('q', 'OR'.join([q_template % (q['q'] or EMPTY_QUERY.get()) for q in query['qs']])),
        ('wt', 'json'),
        ('rows', solr_query['rows']),
        ('start', solr_query['start']),
    )

    if any(collection['facets']):
      params += (
        ('facet', 'true'),
        ('facet.mincount', 0),
        ('facet.limit', 10),
      )
      for facet in collection['facets']:
        if facet['type'] == 'query':
          params += (('facet.query', '%s' % facet['field']),)
        elif facet['type'] == 'range':
          params += tuple([
             ('facet.range', '{!ex=%s}%s' % (facet['field'], facet['field'])),
             ('f.%s.facet.range.start' % facet['field'], facet['properties']['start']),
             ('f.%s.facet.range.end' % facet['field'], facet['properties']['end']),
             ('f.%s.facet.range.gap' % facet['field'], facet['properties']['gap']),
             ('f.%s.facet.mincount' % facet['field'], facet['properties']['mincount']),]
          )
        elif facet['type'] == 'field':
          params += (
              ('facet.field', '{!ex=%s}%s' % (facet['field'], facet['field'])),
              ('f.%s.facet.limit' % facet['field'], int(facet['properties'].get('limit', 10)) + 1),
              ('f.%s.facet.mincount' % facet['field'], int(facet['properties']['mincount'])),
          )

    for fq in query['fqs']:
      if fq['type'] == 'field':
        # This does not work if spaces in Solr:
        # params += (('fq', ' '.join([urllib.unquote(utf_quoter('{!tag=%s}{!field f=%s}%s' % (fq['field'], fq['field'], _filter))) for _filter in fq['filter']])),)
        f = []
        for _filter in fq['filter']:
          if _filter is not None and ' ' in _filter:
            f.append('%s:"%s"' % (fq['field'], _filter))
          else:
            f.append('{!field f=%s}%s' % (fq['field'], _filter))
        params += (('fq', urllib.unquote(utf_quoter('{!tag=%s}' % fq['field'] + ' '.join(f)))),)
      elif fq['type'] == 'range':
        params += (('fq', '{!tag=%s}' % fq['field'] + ' '.join([urllib.unquote(utf_quoter('%s:[%s TO %s}' % (fq['field'], f['from'], f['to']))) for f in fq['properties']])),)

    if collection['template']['fieldsSelected'] and collection['template']['isGridLayout']:
      fields = collection['template']['fieldsSelected'] + [collection['idField']] if collection['idField'] else []
      params += (('fl', urllib.unquote(utf_quoter(','.join(fields)))),)
    else:
      params += (('fl', '*'),)

    params += (
      ('hl', 'true'),
      ('hl.fl', '*'),
      ('hl.snippets', 3)
    )

    if collection['template']['fieldsSelected']:
      fields = []
      for field in collection['template']['fieldsSelected']:
        attribute_field = filter(lambda attribute: field == attribute['name'], collection['template']['fieldsAttributes'])
        if attribute_field:
          if attribute_field[0]['sort']['direction']:
            fields.append('%s %s' % (field, attribute_field[0]['sort']['direction']))
      if fields:
        params += (
          ('sort', ','.join(fields)),
        )

    response = self._root.get('%(collection)s/select' % solr_query, params)

    return self._get_json(response)
开发者ID:findhy,项目名称:hue,代码行数:91,代码来源:api.py

示例10: _get_q

# 需要导入模块: from search.conf import EMPTY_QUERY [as 别名]
# 或者: from search.conf.EMPTY_QUERY import get [as 别名]
 def _get_q(self, query):
   q_template = '(%s)' if len(query['qs']) >= 2 else '%s'
   return 'OR'.join([q_template % (q['q'] or EMPTY_QUERY.get()) for q in query['qs']]).encode('utf-8')
开发者ID:9629831527,项目名称:hue,代码行数:5,代码来源:api.py

示例11: _get_q

# 需要导入模块: from search.conf import EMPTY_QUERY [as 别名]
# 或者: from search.conf.EMPTY_QUERY import get [as 别名]
 def _get_q(self, query):
     q_template = "(%s)" if len(query["qs"]) >= 2 else "%s"
     return "OR".join([q_template % (q["q"] or EMPTY_QUERY.get()) for q in query["qs"]]).encode("utf-8")
开发者ID:fangxingli,项目名称:hue,代码行数:5,代码来源:api.py


注:本文中的search.conf.EMPTY_QUERY.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。