Term vector API: return 'found: false' for docs between index and refresh

Closes #7121
This commit is contained in:
Alex Ksikes 2014-08-01 15:28:49 +02:00
parent 150df5f1c5
commit 62ef4a30dc
4 changed files with 42 additions and 2 deletions

View File

@ -4,7 +4,9 @@
added[1.0.0.Beta1]
Returns information and statistics on terms in the fields of a
particular document as stored in the index.
particular document as stored in the index. Note that this is a
near realtime API as the term vectors are not available until the
next refresh.
[source,js]
--------------------------------------------------

View File

@ -0,0 +1,36 @@
setup:
- do:
indices.create:
index: testidx
body:
settings:
"index.translog.disable_flush": true
"index.number_of_shards": 1
"refresh_interval": -1
mappings:
doc:
"properties":
"text":
"type" : "string"
"term_vector" : "with_positions_offsets"
- do:
index:
index: testidx
type: doc
id: 1
body:
"text" : "foo bar"
---
"Term vector API should return 'found: false' for docs between index and refresh":
- do:
termvector:
index: testidx
type: doc
id: 1
- match: { "_index": "testidx" }
- match: { "_type": "doc" }
- match: { "_id": "1" }
- match: { "found": false }

View File

@ -170,7 +170,6 @@ public class TermVectorResponse extends ActionResponse implements ToXContent {
builder.field(FieldStrings._VERSION, docVersion);
builder.field(FieldStrings.FOUND, isExists());
if (!isExists()) {
builder.endObject();
return builder;
}
builder.startObject(FieldStrings.TERM_VECTORS);

View File

@ -29,6 +29,7 @@ import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.action.admin.indices.alias.Alias;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.mapper.core.AbstractFieldMapper;
@ -70,6 +71,8 @@ public class GetTermVectorTests extends AbstractTermVectorTests {
assertThat(actionGet, notNullValue());
assertThat(actionGet.getIndex(), equalTo("test"));
assertThat(actionGet.isExists(), equalTo(false));
// check response is nevertheless serializable to json
actionGet.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS);
}
}