Skip to content

Commit

Permalink
Index postfix
Browse files Browse the repository at this point in the history
  • Loading branch information
binarymax committed Sep 30, 2020
1 parent 3b86c32 commit ccbdd3c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
8 changes: 4 additions & 4 deletions example/osc-blog.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
"engine_name":"elasticsearch"
}

#skipchunk_config = skipchunk_config_elastic
skipchunk_config = skipchunk_config_solr
skipchunk_config = skipchunk_config_elastic
#skipchunk_config = skipchunk_config_solr

#source = "blog-posts.json"
source = "blog-posts-one.json"
source = "blog-posts.json"
#source = "blog-posts-one.json"

print(timestamp()," | Initializing")

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@
test_suite='tests',
tests_require=test_requirements,
url='https://github.com/o19s/skipchunk',
version='0.9.9',
version='0.9.10',
zip_safe=False,
)
7 changes: 4 additions & 3 deletions skipchunk/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def indexes(self) -> list:
if r.status_code == 200:
#Say cheese
indexes = r.json()
indexes = [i["index"].replace('-' + self.kind,'') for i in indexes if '-'+self.kind in i["index"]]
indexes = [i["index"].replace(self.postfix,'') for i in indexes if self.postfix in i["index"]]

else:
print('ELASTIC ERROR! Cores could not be listed! Have a nice day.')
Expand Down Expand Up @@ -499,11 +499,12 @@ def explore(self,term,contenttype="concept",build=False,quiet=False,branches=10)
# Pretty-prints a graph walk of all suggested concepts and their verbs given a starting term prefix
return []

def __init__(self,host,name,kind,path,enrich_query=None):
def __init__(self,host,name,kind,path,postfix,enrich_query=None):
self.host = host
self.name = name + '-' + kind
self.name = name + postfix
self.kind = kind
self.path = os.path.abspath(path)
self.postfix = postfix

self.root = os.path.join(self.path, name)
self.elastic_home = os.path.join(self.root, 'elastic_'+self.kind)
Expand Down
5 changes: 3 additions & 2 deletions skipchunk/graphquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,18 @@ def __init__(self,config):
self.host = config["host"]
self.name = config["name"]
self.path = config["path"]
self.postfix = "-graph"

self.engine_name = config["engine_name"].lower()

#Setup the search engine
if self.engine_name in ["solr"]:
self.engine_name = "solr"
self.engine = solr.Solr(self.host,self.name,self.kind,self.path)
self.engine = solr.Solr(self.host,self.name,self.kind,self.path,self.postfix)

elif self.engine_name in ["elasticsearch","elastic","es"]:
self.engine_name = "elastic"
self.engine = elastic.Elastic(self.host,self.name,self.kind,self.path)
self.engine = elastic.Elastic(self.host,self.name,self.kind,self.path,self.postfix)


else:
Expand Down
8 changes: 5 additions & 3 deletions skipchunk/indexquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ def __init__(self,config,enrich_query=None):
self.kind = "index"
self.host = config["host"]
self.name = config["name"]
self.engine_name = config["engine_name"].lower()
self.path = config["path"]
self.postfix = ""

self.engine_name = config["engine_name"].lower()

if enrich_query:
self.enrich_query = enrich_query.enrich
Expand All @@ -61,11 +63,11 @@ def __init__(self,config,enrich_query=None):
#Setup the search engine
if self.engine_name in ["solr"]:
self.engine_name = "solr"
self.engine = solr.Solr(self.host,self.name,self.kind,self.path,self.enrich_query)
self.engine = solr.Solr(self.host,self.name,self.kind,self.path,self.postfix,enrich_query=self.enrich_query)

elif self.engine_name in ["elasticsearch","elastic","es"]:
self.engine_name = "elastic"
self.engine = elastic.Elastic(self.host,self.name,self.kind,self.path,self.enrich_query)
self.engine = elastic.Elastic(self.host,self.name,self.kind,self.path,self.postfix,enrich_query=self.enrich_query)

else:
raise ValueError("Sorry! Only Solr or Elastic are currently supported")
Expand Down
7 changes: 4 additions & 3 deletions skipchunk/solr.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def indexes(self,kind=None) -> list:
if r.status_code == 200:
#Say cheese
cores = list(r.json()['status'].keys())
cores = [c.replace('-' + self.kind,'') for c in cores if self.kind in c]
cores = [c.replace(self.postfix,'') for c in cores if self.postfix in c]

else:
print('SOLR ERROR! Cores could not be listed! Have a nice day.')
Expand Down Expand Up @@ -419,11 +419,12 @@ def explore(self,term,contenttype="concept",build=False,quiet=False,branches=10)

return tree

def __init__(self,host,name,kind,path,enrich_query=None):
def __init__(self,host,name,kind,path,postfix,enrich_query=None):
self.host = host
self.name = name + '-' + kind
self.name = name + postfix
self.kind = kind
self.path = os.path.abspath(path)
self.postfix = postfix
self.solr_uri = self.host + self.name

self.root = os.path.join(self.path, name)
Expand Down

0 comments on commit ccbdd3c

Please sign in to comment.