-
Notifications
You must be signed in to change notification settings - Fork 1.2k
why can't search anyting, including no condition #2809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hello, can you please provide more details? What query did you try to run, and what results did you expect? |
result = es.search(index='news') |
my code from elasticsearch import Elasticsearch
import json
es = Elasticsearch(
"https://elastic:E3VUUEUJ5GcLxc2Pp%3D7s@localhost:9200/",
verify_certs=False,
ssl_show_warn=False,
)
es.options(ignore_status=404).indices.delete(index="news")
es.options(ignore_status=400).indices.create(index="news")
for data in enumerate(json.load(open("novel_data.json", encoding="UTF-8"))):
es.create(index="news", id=str(data[0]), body=data[1])
print(f"数据插入成功 id: {data[0]}")
data = {
"title": "985保送路线有哪些?",
}
status = es.update(index="news", id="3", body={"doc": data})
print(status)
doc = es.get(index="news", id="3")
print(doc)
status = es.delete(index="news", id="3")
print(status)
result = es.search(index="news")
print(result) output:
|
Elasticsearch is a near real time system, where documents are not indexed directly after having been created: https://www.elastic.co/guide/en/elasticsearch/reference/current/near-real-time.html. Get, update and delete are not affected, but search is. To fix this, you need to either wait or refresh your index before searching: es.indices.refresh(index="news")
result = es.search(index="news")
print(result) |
Oh, thank you. |
{'took': 0, 'timed_out': False, '_shards': {'total': 1, 'successful': 1, 'skipped': 0, 'failed': 0}, 'hits': {'total': {'value': 0, 'relation': 'eq'}, 'max_score': None, 'hits': []}}
The text was updated successfully, but these errors were encountered: