0

I'm trying to delete an index, which works fine, but then when I attempt to add items and search for them it doesn't work.

Example:

es = Elasticsearch([{'host': 'localhost', 'port': 9200}])


def get_all_entries():
    doc = {
        'size' : 10000,
        'query': {
            'match_all' : {}
        }
    }
    return es.search(index='faqs', doc_type='en', body=doc)

es = Elasticsearch([{'host': 'localhost', 'port': 9999}])

print(es.indices.delete(index='faqs', ignore=[400, 404]))
print()

for entry in entries:
    resp = es.index(index='faqs', doc_type='en', body=entry) #If id is not specified, it's auto
    print(resp)

print(get_all_entries()['hits']['total'])

This prints {'relation': 'eq', 'total': 0}

But if I remove the delete line, the print is {'relation': 'eq', 'total': 2}. However, in indexing the entries, it is returning result: created.

thethiny
  • 1,125
  • 1
  • 10
  • 26

0 Answers0