Skip to content

Commit

Permalink
Prepare searchengine for elastic search 8
Browse files Browse the repository at this point in the history
  • Loading branch information
peace-maker committed Jul 21, 2023
1 parent 8ecf259 commit 54a54cb
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions searchengine/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/__pycache__/
**/node_modules/
2 changes: 1 addition & 1 deletion searchengine/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8-slim-buster AS uwsgi
FROM python:3.10-slim-bullseye AS uwsgi

ENV PYTHONUNBUFFERED 1
WORKDIR /app
Expand Down
2 changes: 1 addition & 1 deletion searchengine/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def find(body, extra_symbols=[]):
)

query = {"bool": {"filter": filters}}
res = es.search(index=config.ES_INDEX_NAME, body={"query": query})
res = es.search(index=config.ES_INDEX_NAME, query=query)

libcs = []
for hit in res['hits']['hits']:
Expand Down
2 changes: 1 addition & 1 deletion searchengine/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
tag: uwsgi

es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.7
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.10
container_name: es01
environment:
- node.name=es01
Expand Down
8 changes: 4 additions & 4 deletions searchengine/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ def get_build_id(fname):
p.add_argument('dir')
args = p.parse_args()

es = Elasticsearch()
es = Elasticsearch(hosts=["http://localhost:9200"])

if args.fresh:
es.indices.delete(args.index, ignore=[404])
es.indices.delete(index=args.index, ignore=[404])

es.indices.create(args.index, ignore=[400])
es.indices.create(index=args.index, ignore=[400])
es.indices.put_mapping(index=args.index, doc_type='libc', body={
'libc': {
"properties": {
Expand Down Expand Up @@ -98,7 +98,7 @@ def get_build_id(fname):
buildid = get_build_id(libc_fname)
if buildid:
doc['buildid'] = buildid
es.create(index=args.index, id=id, body=doc)
es.create(index=args.index, id=id, document=doc)

es.indices.refresh(index=args.index)

Expand Down
2 changes: 1 addition & 1 deletion searchengine/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
elasticsearch
elasticsearch>=7.16,<8
connexion
uwsgi
flask-cors

0 comments on commit 54a54cb

Please sign in to comment.