Created
March 6, 2018 22:29
-
-
Save sstults/9295e383807caec2b7d919a9e6f20972 to your computer and use it in GitHub Desktop.
Quick and sloppy script to clear out unused fields from Solr's schema API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from urllib.parse import urlencode | |
from urllib.request import Request, urlopen | |
solr_url = 'http://localhost:8983/solr/gettingstarted/schema' | |
luke_file = open('luke-json-output.json', 'r') | |
luke_json = json.load(luke_file) | |
luke_file.close() | |
for field in luke_json['fields']: | |
if 'docs' not in luke_json['fields'][field]: | |
post_fields = {'delete-field': {"name": field}} | |
request = Request(solr_url, urlencode(post_fields).encode()) | |
urlopen(request).read().decode() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment