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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hoppysearch-0.0.13.tar.gz.
File metadata
- Download URL: hoppysearch-0.0.13.tar.gz
- Upload date:
- Size: 19.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e92a1727d1b8090832a1f38656d2d8c8e4d4ed9209b59bfb5a4ef20328e08d1b
|
|
| MD5 |
d975117a7b008075d5a9b7958f887ffe
|
|
| BLAKE2b-256 |
c5aaa0251d316246efe7f67f23103fbc2896ac04dbc9b6f377d80fd9a12b40be
|
File details
Details for the file hoppysearch-0.0.13-py3-none-any.whl.
File metadata
- Download URL: hoppysearch-0.0.13-py3-none-any.whl
- Upload date:
- Size: 19.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10e3d5b7ad137cfaf1e7477175057e0c056b15f367aa121ff5524a288e28b1d3
|
|
| MD5 |
e5d6d68a330d389a4edd129e2f212b1f
|
|
| BLAKE2b-256 |
ee91f4b610875c0fb0233a9a1a11d384e01f01899818ba7882a88532fca462aa
|