<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          PysolrSolr 輕量的 Python 應(yīng)用

          聯(lián)合創(chuàng)作 · 2023-09-29 03:37

          Pysolr,是基于Python的Apache Solr輕量級封裝。它提供了服務(wù)器查詢并返回基于查詢的結(jié)果接口。

          特性:

          • 基本功能,選擇、更新和刪除

          • 索引優(yōu)化

          • 超時支持

          使用環(huán)境:

          • Python 2.7 - 3.5

          • Requests 2.0+

          • Optional - simplejson

          • Optional - kazoo for SolrCloud mode

          示例代碼:

          # If on Python 2.X
          from __future__ import print_function
          import pysolr
          # Setup a Solr instance. The timeout is optional.
          solr = pysolr.Solr('http://localhost:8983/solr/', timeout=10)
          # How you'd index data.
          solr.add([
              {
                  "id": "doc_1",
                  "title": "A test document",
              },
              {
                  "id": "doc_2",
                  "title": "The Banana: Tasty or Dangerous?",
              },
          ])
          # Later, searching is easy. In the simple case, just a plain Lucene-style
          # query is fine.
          results = solr.search('bananas')
          # The ``Results`` object stores total results found, by default the top
          # ten most relevant results and any additional data like
          # facets/highlighting/spelling/etc.
          print("Saw {0} result(s).".format(len(results)))
          # Just loop over it to access the results.
          for result in results:
              print("The title is '{0}'.".format(result['title']))
          # For a more advanced query, say involving highlighting, you can pass
          # additional options to Solr.
          results = solr.search('bananas', **{
              'hl': 'true',
              'hl.fragsize': 10,
          })
          # You can also perform More Like This searches, if your Solr is configured
          # correctly.
          similar = solr.more_like_this(q='id:doc_2', mltfl='text')
          # Finally, you can delete either individual documents...
          solr.delete(id='doc_1')
          # ...or all documents.
          solr.delete(q='*:*')
          # For SolrCloud mode, initialize your Solr like this:
          zookeeper = pysolr.Zookeeper("zkhost1:2181,zkhost2:2181,zkhost3:2181")
          solr = pysolr.SolrCloud(zookeeper, "collection1")
          瀏覽 18
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評論
          圖片
          表情
          推薦
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  激情乱伦网站 | 爱爱视频欧美 | 精品人妻无码一区二区出白浆潮喷 | 国产五月丁香好好日 | 翔田千里无遮挡全棵 |