Skip to content
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

Clarify realtime get API documentation #45717

Closed
dadoonet opened this issue Aug 20, 2019 · 5 comments
Closed

Clarify realtime get API documentation #45717

dadoonet opened this issue Aug 20, 2019 · 5 comments
Labels
:Distributed Indexing/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. >docs General docs changes

Comments

@dadoonet
Copy link
Member

Reported at: https://discuss.elastic.co/t/the-id-query-will-trigger-refresh-but-i-still-cant-search-with-query-qsl/195829

The documentation states:

If a document has been updated but is not yet refreshed, the get API will issue a refresh call in-place to make the document visible. This will also make other documents changed since the last refresh visible.

But the following script does not seem to prove it:

DELETE test
PUT test 
{
  "settings": {
    "refresh_interval": "-1"
  }
}
PUT test/_doc/1
{
  "foo": "bar"
}

This gives empty results:

GET test/_search

This gives empty results although we called the GET API:

GET test/_doc/1
GET test/_search

This works when we manually refresh the index:

POST test/_refresh
GET test/_search

So the documentation is not entirely exact about what is happening behind the scene. May be it's because I have only one document and some threshold are involved here?

@unlikezy
Copy link

unlikezy commented Aug 20, 2019

I encounter the exactly same situation.
What I want to add is:
if you disable realtime when get

GET test/_doc/1?realtime=false

the result will be:

{
  "_index" : "test",
  "_type" : "_doc",
  "_id" : "1",
  "found" : false
}

and if you enable realtime, which is default, you can get the doc:

GET test/_doc/1?realtime=true
{
  "_index" : "test",
  "_type" : "_doc",
  "_id" : "1",
  "_version" : 1,
  "_seq_no" : 0,
  "_primary_term" : 1,
  "found" : true,
  "_source" : {
    "foo" : "bar"
  }
}

Changing HTTP method from GET to HEAD in above examples also illustrate this problem, but might see this more clearly.

I am curious about why GET work without refreshing data into Lucene index, and how is the performance.

@dliappis dliappis added the :Distributed Indexing/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. label Aug 20, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

@dliappis dliappis added the >docs General docs changes label Aug 20, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-docs

@jrodewig
Copy link
Contributor

jrodewig commented Oct 4, 2019

[docs issue triage]

Leaving open as this is still relevant.

@ywelsch
Copy link
Contributor

ywelsch commented Dec 2, 2019

The documentation was imprecise here. ES distinguishes between internal and external refreshes. Internal refreshes are used to build segments, whereas external refreshes are used to expose these newly built segments. In case where a document is accessed using a realtime get, and the document is still in the Lucene buffer (i.e. not internally refreshed yet), Elasticsearch triggers an internal refresh. This is why you can't observed the "internally refreshed" document.

Note that all of this is changing in ES 7.6+ (see #48843). From that version on, realtime get will not trigger a refresh anymore, making all these explanations moot. The docs in newer versions have been updated to that effect.

@ywelsch ywelsch closed this as completed Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Indexing/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. >docs General docs changes
Projects
None yet
Development

No branches or pull requests

6 participants