コード例 #1
0
# created_cluster = retrieve_and_rank.create_solr_cluster(cluster_name='Test Cluster', cluster_size='1')
# print(json.dumps(created_cluster, indent=2))

# Replace with your own solr_cluster_id
solr_cluster_id = 'sc31a30e84_9094_4af2_93af_a8751257d4cc'

status = retrieve_and_rank.get_solr_cluster_status(solr_cluster_id=solr_cluster_id)
print(json.dumps(status, indent=2))

# Solr cluster config
# with open('../resources/solr_config.zip', 'rb') as config:
#     config_status = retrieve_and_rank.create_config(solr_cluster_id, 'test-config', config)
#     print(json.dumps(config_status, indent=2))

configs = retrieve_and_rank.list_configs(solr_cluster_id=solr_cluster_id)
print(json.dumps(configs, indent=2))

# collection = retrieve_and_rank.create_collection(solr_cluster_id, 'test-collection', 'test-config')
# print(json.dumps(collection, indent=2))

collections = retrieve_and_rank.list_collections(solr_cluster_id=solr_cluster_id)
print(json.dumps(collections, indent=2))

pysolr_client = retrieve_and_rank.get_pysolr_client(solr_cluster_id, 'test-collection')
results = pysolr_client.search('bananas')
print(results.docs)

# Rankers

# rankers = retrieve_and_rank.list_rankers()
コード例 #2
0
    opts, args = getopt.getopt(sys.argv[1:], 'hdi:', ['cluster_id='])
except getopt.GetoptError as err:
    print(str(err))
    print(usage())
    sys.exit(2)

for opt, arg in opts:
    if opt == '-h':
        usage()
        sys.exit()
    elif opt in ('-i', '---cluster_id'):
        cluster_id = arg
    elif opt == '-d':
        DEBUG = True

if not cluster_id:
    print('Required argument missing.')
    usage()
    sys.exit(2)

try:
    # list Solr config
    retrieve_and_rank = RetrieveAndRank(url=rnrConstants.getUrl(),
                                        username=rnrConstants.getUsername(),
                                        password=rnrConstants.getPassword())
    res = retrieve_and_rank.list_configs(cluster_id)
    sys.stdout.write('Response: \n%s\n' % json.dumps(res, indent=2))

except Exception as e:
    sys.stdout.write(str(e))
    exit(1)
コード例 #3
0
# created_cluster = retrieve_and_rank.create_solr_cluster(cluster_name='Test Cluster', cluster_size='1')
# print(json.dumps(created_cluster, indent=2))

# Replace with your own solr_cluster_id
solr_cluster_id = 'sc31a30e84_9094_4af2_93af_a8751257d4cc'

status = retrieve_and_rank.get_solr_cluster_status(
    solr_cluster_id=solr_cluster_id)
print(json.dumps(status, indent=2))

# Solr cluster config
# with open('../resources/solr_config.zip', 'rb') as config:
#     config_status = retrieve_and_rank.create_config(solr_cluster_id, 'test-config', config)
#     print(json.dumps(config_status, indent=2))

configs = retrieve_and_rank.list_configs(solr_cluster_id=solr_cluster_id)
print(json.dumps(configs, indent=2))

# collection = retrieve_and_rank.create_collection(solr_cluster_id, 'test-collection', 'test-config')
# print(json.dumps(collection, indent=2))

collections = retrieve_and_rank.list_collections(
    solr_cluster_id=solr_cluster_id)
print(json.dumps(collections, indent=2))

pysolr_client = retrieve_and_rank.get_pysolr_client(solr_cluster_id,
                                                    'test-collection')
results = pysolr_client.search('bananas')
print(results.docs)

# Rankers
コード例 #4
0
try:
    opts, args = getopt.getopt(sys.argv[1:],'hdi:',['cluster_id='])
except getopt.GetoptError as err:
    print(str(err))
    print(usage())
    sys.exit(2)
    
for opt, arg in opts:
    if opt == '-h':
        usage()
        sys.exit()
    elif opt in ('-i', '---cluster_id'):
        cluster_id = arg
    elif opt == '-d':
        DEBUG = True

if not cluster_id:
    print('Required argument missing.')
    usage()
    sys.exit(2)

try:
    # list Solr config
    retrieve_and_rank = RetrieveAndRank(url=rnrConstants.getUrl(), username=rnrConstants.getUsername(), password=rnrConstants.getPassword())
    res = retrieve_and_rank.list_configs(cluster_id)
    sys.stdout.write('Response: \n%s\n' % json.dumps(res, indent=2))

except Exception as e:
    sys.stdout.write(str(e))
    exit(1)