Hoppysearch Search JavaScript Client
Project description
hoppysearch
hoppysearch - Python client for hoppysearch
Requirements.
Python 2.7 and 3.4+
Installation & Usage
pip install
Install it via:
pip install hoppysearch
Then import the package:
from hoppysearch import HoppySearch, ApiException
Getting Started
Please follow the installation procedure and then run the following:
Initial configuration:
from hoppysearch import HoppySearch, ApiException
index_id = YOUR_INDEX_ID
api_key = YOUR_API_KEY
hoppysearch = HoppySearch(index_id, api_key )
index
Please add the below code after Initial configuration to index your data.
documents = [
{
"Id": 101872,
"ProductId": "B000DZH1D6",
"UserId": "A1HKBX2L0DV258",
"ProfileName": "Dena Leasure",
"HelpfulnessNumerator": 0,
"HelpfulnessDenominator": 0,
"Score": 5,
"Time": 1259625600,
"Summary": "Gluten free cookies",
"Text": "These are the best cookies I have found that are gluten free. I love them!"
}
]
optionals = {
"configType": "create",
"diag": "true"
}
try:
response = hoppysearch.index(documents, optionals)
print(response)
except ApiException as e:
print("Exception: %s\n" % e)
The second argument of hoppysearch.index is not mandatory. You can skip it fully or you can skip any key value according to your requirement.
# skip second argument
documents = [
{
"Id": 101872,
"ProductId": "B000DZH1D6",
"UserId": "A1HKBX2L0DV258",
"ProfileName": "Dena Leasure",
"HelpfulnessNumerator": 0,
"HelpfulnessDenominator": 0,
"Score": 5,
"Time": 1259625600,
"Summary": "Gluten free cookies",
"Text": "These are the best cookies I have found that are gluten free. I love them!"
}
]
try:
response = hoppysearch.index(documents)
print(response)
except ApiException as e:
print("Exception: %s\n" % e)
# skip some key of second argument
documents = [
{
"Id": 101872,
"ProductId": "B000DZH1D6",
"UserId": "A1HKBX2L0DV258",
"ProfileName": "Dena Leasure",
"HelpfulnessNumerator": 0,
"HelpfulnessDenominator": 0,
"Score": 5,
"Time": 1259625600,
"Summary": "Gluten free cookies",
"Text": "These are the best cookies I have found that are gluten free. I love them!"
}
]
optionals = {
"diag": "true"
}
try:
response = hoppysearch.index(documents)
print(response)
except ApiException as e:
print("Exception: %s\n" % e)
You can pass file object or file path to upload data to index.
# filepath
documents = "C:/Users/Pragyan/Desktop/books.json"
try:
response = hoppysearch.index(documents)
print(response)
except ApiException as e:
print("Exception: %s\n" % e)
# fileobj
documents = open("C:/Users/Pragyan/Desktop/books.json", "r")
try:
response = hoppysearch.index(documents)
print(response)
except ApiException as e:
print("Exception: %s\n" % e)
search
First add the configuration as mentioned above and then add below code to search.
query = "cookies"
optionals = {
"searchableKeyList": "Summary, Text",
"diag": "true",
"showStats": "true",
"pageSize": 10,
"pageIndex": 0
}
try:
response = hoppysearch.search(query, optionals)
print(response)
except ApiException as e:
print("Exception: %s\n" % e)
The second argument of hoppysearch.search is not mandatory. You can skip it fully or you can skip any key value according to your requirement.
# skip second argument
query = "cookies"
try:
response = hoppysearch.search(query)
print(response)
except ApiException as e:
print("Exception: %s\n" % e)
# skip some key of second argument
query = "cookies"
optionals = {
"searchableKeyList": "Summary, Text",
"pageSize": 10,
"pageIndex": 0
}
try:
response = hoppysearch.search(query)
print(response)
except ApiException as e:
print("Exception: %s\n" % e)
luceneSearch
First add the configuration as mentioned above and then add below code to perform search in advaced way.
luceneQuery = "Text: cookies"
optionals = {
"defaultKeyNameToBeSearch": "Summary",
"analyzerClass": "org.apache.lucene.analysis.standard.StandardAnalyzer",
"diag": True,
"showStats": True,
"pageSize": 10,
"pageIndex": 0
}
try:
response = hoppysearch.lucene_search(luceneQuery, optionals)
print(response)
except ApiException as e:
print("Exception: %s\n" % e)
The second argument of hoppysearch.lucene_search is not mandatory. You can skip it fully or you can skip any key value according to your requirement.
# skip second argument
luceneQuery = "Text: cookies"
try:
response = hoppysearch.lucene_search(luceneQuery)
print(response)
except ApiException as e:
print("Exception: %s\n" % e)
# skip some key of second argument
luceneQuery = "Text: cookies"
optionals = {
"defaultKeyNameToBeSearch": "Summary",
"pageSize": 10,
"pageIndex": 0
}
try:
response = hoppysearch.lucene_search(luceneQuery, optionals)
print(response)
except ApiException as e:
print("Exception: %s\n" % e)
delete
First add the configuration as mentioned above and then add below code to delete specific data from index.
hs_guid = "15b522d8-1545-4dc9-9160-0b512f7d6997"
optionals = {
"diag": True,
"showStats": True
}
try:
response = hoppysearch.delete(hs_guid, optionals)
print(response)
except ApiException as e:
print("Exception: %s\n" % e)
The second argument of hoppysearch.delete is not mandatory. You can skip it fully or you can skip any key value according to your requirement.
# skip second argument
hs_guid = "15b522d8-1545-4dc9-9160-0b512f7d6997"
try:
response = hoppysearch.delete(hs_guid)
print(response)
except ApiException as e:
print("Exception: %s\n" % e)
# skip some key of second argument
hs_guid = "15b522d8-1545-4dc9-9160-0b512f7d6997"
optionals = {
"diag": True
}
try:
response = hoppysearch.delete(hs_guid, optionals)
print(response)
except ApiException as e:
print("Exception: %s\n" % e)
stats
First add the configuration as mentioned above and then add below code to get stats.
try:
response = hoppysearch.stats()
print(response)
except ApiException as e:
print("Exception: %s\n" % e)
clearIndex
First add the configuration as mentioned above and then add below code to clear all data from your index.
try:
response = hoppysearch.clear_index()
print(response)
except ApiException as e:
print("Exception: %s\n" % e)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for hoppysearch-0.0.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c013a62ed0c349570312fe8636b6efa64b3ce1fa14713ae026d5028e5d90ad2 |
|
MD5 | 014b39969f8b343a0d66d73ece367eb6 |
|
BLAKE2b-256 | 36589299e38483f251e1ecdc2567ec91f208eb06e3bffceaf26cb88a88e73eb9 |