• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python conf.EMPTY_QUERY类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: query

  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,代码行数:27,代码来源:api.py


示例2: stats

 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,代码行数:13,代码来源:api.py


示例3: stats

  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,代码行数:16,代码来源:api.py


示例4: query

  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,代码行数:20,代码来源:api.py


示例5: stats

    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,代码行数:21,代码来源:api.py


示例6: query

  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,代码行数:21,代码来源:api.py


示例7: query

    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,代码行数:24,代码来源:api.py


示例8: query

  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,代码行数:24,代码来源:api.py


示例9: query

  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,代码行数:89,代码来源:api.py


示例10: _get_q

 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,代码行数:3,代码来源:api.py


示例11: _get_q

 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,代码行数:3,代码来源:api.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python conf.SOLR_URL类代码示例发布时间:2022-05-27
下一篇:
Python clients.WikiClient类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap