Python Operations SOLR Index Library

Source: Internet
Author: User
Tags solr ssl certificate

Add/Update (OVERWRITE=TRUE)

# Coding=utf-8import Requestsdata = {"Add": {"Doc": {"id": "10001", "Item_title": "I am a good person"}}}     # The data to add params = {" Boost ": 1.0," Overwrite ":" true "," Commitwithin ": +   # Overwrite: If there is already data for this ID in SOLR, overwrite it with url = '/http ' 127.0.0.1:8080/solr/collection1/update?wt=json '   # request urlheaders = {"Content-type": "Application/json"}  # Request header (indicates that the content is in JSON format) R = Requests.post (URL, json = data, params = params, headers = headers) # Send request print (R.text)   # {"Respo Nseheader ": {" status ": 0," Qtime ": 2}}

Inquire

Import Requestsitem = "I Am"     # search field url = ' http://127.0.0.1:8080/solr/collection1/select?q=item_title: ' \%s ' &wt= Json&indent=true '%item   # request url# verify=true-Check SSL certificate for a host R = Requests.get (URL, verify = False)   # Send request, corresponding: R = <response [200]>r = R.json ()    # turns it into JSON format print (R) "" "{' Responseheader ': {' qtime ': 1, ' status ': 0, ' params ': {' Q ': ' item_title: ' \ \ I ' ', ' Indent ': ' true ', ' wt ': ' JSON '}, ' response ': {' numfound ': 1, ' Start ': 0, ' docs ': [{' _version_ ': 1597870382723891200, ' id ': ' 100001 ', ' item_title ': ' I'm a good person '}]}}numfound--how many related data--the query set returned (list) "" "

Python Operations SOLR Index Library

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.