Source filtering with wildcards broken when given multiple patterns
``` curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '{ "user" : "kimchy", "post_date" : "2009-11-15T14:12:12", "message" : "trying out Elasticsearch", "retweeted": false }' ``` No source fields delivered: ``` curl -XGET 'http://localhost:9200/twitter/tweet/1?_source=*.id,retweeted&pretty=yes' ``` `retweeted` returned: ``` curl -XGET 'http://localhost:9200/twitter/tweet/1?_source=retweeted,*.id&pretty=yes' ``` Closes #5132. Closes #5133.
This commit is contained in:
parent
e379f419e6
commit
5d159369ef
|
@ -175,7 +175,7 @@ public class XContentMapValues {
|
|||
break;
|
||||
}
|
||||
pathIsPrefixOfAnInclude = true;
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
if (include.startsWith(path)) {
|
||||
if (include.length() == path.length()) {
|
||||
|
@ -184,7 +184,7 @@ public class XContentMapValues {
|
|||
} else if (include.length() > path.length() && include.charAt(path.length()) == '.') {
|
||||
// include might may match deeper paths. Dive deeper.
|
||||
pathIsPrefixOfAnInclude = true;
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (Regex.simpleMatch(include, path)) {
|
||||
|
|
|
@ -81,5 +81,26 @@ public class SourceFetchingTests extends ElasticsearchIntegrationTest {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Case for #5132: Source filtering with wildcards broken when given multiple patterns
|
||||
* https://github.com/elasticsearch/elasticsearch/issues/5132
|
||||
*/
|
||||
@Test
|
||||
public void testSourceWithWildcardFiltering() {
|
||||
createIndex("test");
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test", "type1", "1").setSource("field", "value").get();
|
||||
refresh();
|
||||
|
||||
SearchResponse response = client().prepareSearch("test").setFetchSource(new String[]{"*.notexisting","field"}, null).get();
|
||||
assertThat(response.getHits().getAt(0).getSourceAsString(), notNullValue());
|
||||
assertThat(response.getHits().getAt(0).getSource().size(), equalTo(1));
|
||||
assertThat((String) response.getHits().getAt(0).getSource().get("field"), equalTo("value"));
|
||||
|
||||
response = client().prepareSearch("test").setFetchSource(new String[]{"field.notexisting.*","field"}, null).get();
|
||||
assertThat(response.getHits().getAt(0).getSourceAsString(), notNullValue());
|
||||
assertThat(response.getHits().getAt(0).getSource().size(), equalTo(1));
|
||||
assertThat((String) response.getHits().getAt(0).getSource().get("field"), equalTo("value"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue