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

Always return metadata in get/search APIs. #11816

Merged
merged 1 commit into from Jun 24, 2015

Conversation

jpountz
Copy link
Contributor

@jpountz jpountz commented Jun 23, 2015

This commit makes the get and search APIs always return _parent, _routing,
_timestamp and _ttl in addition to _id and _type. This way, consumers
always have all required information in order to reindex a document.

Closes #8068

@@ -138,7 +139,7 @@ public void testExplainWithFields() throws Exception {
assertThat(response.getExplanation().getValue(), equalTo(1.0f));
assertThat(response.getGetResult().isExists(), equalTo(true));
assertThat(response.getGetResult().getId(), equalTo("1"));
assertThat(response.getGetResult().getFields().size(), equalTo(1));
assertThat(response.getGetResult().getFields().size(), greaterThanOrEqualTo(1));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this greaterThanOrEqualTo()? Do we not know how many metadata fields we should get returned here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have random index templates that enable _timestamp for instance, which will be part of the list of return fields now that we force it to be returned when enabled.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I didn't know that, thanks. I wonder if there is some way we can get the list of fields that have been randomly added? The problem I see here is that we aren't really testing that only the requesting fields are returned.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could change the assertion to something like fields.keySet().containsAll(Arrays.asList(expectedField1, expectedField2))?

@jpountz
Copy link
Contributor Author

jpountz commented Jun 23, 2015

@colings86 I pushed a new commit

} else if (field.equals(TimestampFieldMapper.NAME) && docMapper.timestampFieldMapper().enabled()) {
value = source.timestamp;
} else if (field.equals(TTLFieldMapper.NAME) && docMapper.TTLFieldMapper().enabled()) {
// Call value for search with timestamp + ttl here to display the live remaining ttl value and be consistent with the search result display
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to -> so

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops nevermind, I misread.

@rjernst
Copy link
Member

rjernst commented Jun 23, 2015

LGTM

This commit makes the get and search APIs always return `_parent`, `_routing`,
`_timestamp` and `_ttl` in addition to `_id` and `_type`. This way, consumers
always have all required information in order to reindex a document.
@jpountz jpountz force-pushed the enhancement/return_metadata branch from 0801d88 to e4d475c Compare June 24, 2015 08:32
jpountz added a commit that referenced this pull request Jun 24, 2015
Always return metadata in get/search APIs.
@jpountz jpountz merged commit 121a699 into elastic:master Jun 24, 2015
@kevinkluge kevinkluge removed the review label Jun 24, 2015
@jpountz jpountz deleted the enhancement/return_metadata branch June 24, 2015 08:33
@jpountz jpountz added the :Search/Search Search-related issues that do not fall into other categories label Jun 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants