This PR allows easy drop-in replacement for the SimpleIndexer. Changes needed in the wikipedia-example:
# flows/flow.yml
- uses: 'jinahub://SimpleIndexer' # We use the SimpleIndexer for this purpose
+ uses: 'jinahub+docker://FaissPostgresSearcher
# app.py Add roughly the following code
def all_in_one(num_docs, top_k):
flow = Flow().load_config('flows/flow.yml')
data_path = os.path.join(
os.path.dirname(__file__), os.environ.get('JINA_DATA_FILE', None)
)
with flow:
flow.post(
on='/index', inputs=input_generator(num_docs, data_path), show_progress=True
)
flow.post(on='/dump', parameters={'dump_path': 'my_dump.dump', 'shards': 1})
flow.post(on='/reload', parameters={'dump_path': 'my_dump.dump'})
while True:
text = input('Please type a sentence: ')
doc = Document(content=text)
result = flow.post(
on='/search',
inputs=DocumentArray([doc]),
parameters={'top_k': top_k},
line_format='text',
return_results=True,
)
print_topk(result[0], text)
The all_in_one is a combination of /index and /query combined into one Flow. The additional lines are actually only flow.post(on='/dump'...) and flow.post(on='/reload'...). They will be combined into one in the future.
This PR allows easy drop-in replacement for the SimpleIndexer. Changes needed in the wikipedia-example:
The
all_in_one
is a combination of/index
and/query
combined into one Flow. The additional lines are actually onlyflow.post(on='/dump'...)
andflow.post(on='/reload'...)
. They will be combined into one in the future.