Fix compile errors due to upstream changes in HasChild- and HasParentQueryBuilder

Original commit: elastic/x-pack-elasticsearch@9945e89b6e
This commit is contained in:
Martijn van Groningen 2016-04-14 14:46:08 +02:00
parent 1ef246adab
commit 5f7220dea4
2 changed files with 12 additions and 10 deletions

View File

@ -5,6 +5,7 @@
*/ */
package org.elasticsearch.integration; package org.elasticsearch.integration;
import org.apache.lucene.search.join.ScoreMode;
import org.elasticsearch.ElasticsearchSecurityException; import org.elasticsearch.ElasticsearchSecurityException;
import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.get.MultiGetResponse; import org.elasticsearch.action.get.MultiGetResponse;
@ -548,13 +549,13 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
refresh(); refresh();
SearchResponse searchResponse = client().prepareSearch("test") SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(hasChildQuery("child", matchAllQuery())) .setQuery(hasChildQuery("child", matchAllQuery(), ScoreMode.None))
.get(); .get();
assertHitCount(searchResponse, 1L); assertHitCount(searchResponse, 1L);
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1")); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
searchResponse = client().prepareSearch("test") searchResponse = client().prepareSearch("test")
.setQuery(hasParentQuery("parent", matchAllQuery())) .setQuery(hasParentQuery("parent", matchAllQuery(), false))
.addSort("_uid", SortOrder.ASC) .addSort("_uid", SortOrder.ASC)
.get(); .get();
assertHitCount(searchResponse, 3L); assertHitCount(searchResponse, 3L);
@ -565,39 +566,39 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
// Both user1 and user2 can't see field1 and field2, no parent/child query should yield results: // Both user1 and user2 can't see field1 and field2, no parent/child query should yield results:
searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD))) searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD)))
.prepareSearch("test") .prepareSearch("test")
.setQuery(hasChildQuery("child", matchAllQuery())) .setQuery(hasChildQuery("child", matchAllQuery(), ScoreMode.None))
.get(); .get();
assertHitCount(searchResponse, 0L); assertHitCount(searchResponse, 0L);
searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD))) searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
.prepareSearch("test") .prepareSearch("test")
.setQuery(hasChildQuery("child", matchAllQuery())) .setQuery(hasChildQuery("child", matchAllQuery(), ScoreMode.None))
.get(); .get();
assertHitCount(searchResponse, 0L); assertHitCount(searchResponse, 0L);
searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD))) searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD)))
.prepareSearch("test") .prepareSearch("test")
.setQuery(hasParentQuery("parent", matchAllQuery())) .setQuery(hasParentQuery("parent", matchAllQuery(), false))
.get(); .get();
assertHitCount(searchResponse, 0L); assertHitCount(searchResponse, 0L);
searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD))) searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
.prepareSearch("test") .prepareSearch("test")
.setQuery(hasParentQuery("parent", matchAllQuery())) .setQuery(hasParentQuery("parent", matchAllQuery(), false))
.get(); .get();
assertHitCount(searchResponse, 0L); assertHitCount(searchResponse, 0L);
// user 3 can see them but not c3 // user 3 can see them but not c3
searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD))) searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD)))
.prepareSearch("test") .prepareSearch("test")
.setQuery(hasChildQuery("child", matchAllQuery())) .setQuery(hasChildQuery("child", matchAllQuery(), ScoreMode.None))
.get(); .get();
assertHitCount(searchResponse, 1L); assertHitCount(searchResponse, 1L);
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1")); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD))) searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD)))
.prepareSearch("test") .prepareSearch("test")
.setQuery(hasParentQuery("parent", matchAllQuery())) .setQuery(hasParentQuery("parent", matchAllQuery(), false))
.get(); .get();
assertHitCount(searchResponse, 2L); assertHitCount(searchResponse, 2L);
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c1")); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c1"));

View File

@ -5,6 +5,7 @@
*/ */
package org.elasticsearch.integration; package org.elasticsearch.integration;
import org.apache.lucene.search.join.ScoreMode;
import org.elasticsearch.ElasticsearchSecurityException; import org.elasticsearch.ElasticsearchSecurityException;
import org.elasticsearch.action.fieldstats.FieldStatsResponse; import org.elasticsearch.action.fieldstats.FieldStatsResponse;
import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.get.GetResponse;
@ -1177,7 +1178,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
SearchResponse searchResponse = client() SearchResponse searchResponse = client()
.filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD))) .filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD)))
.prepareSearch("test") .prepareSearch("test")
.setQuery(hasChildQuery("child", termQuery("field1", "yellow"))) .setQuery(hasChildQuery("child", termQuery("field1", "yellow"), ScoreMode.None))
.get(); .get();
assertHitCount(searchResponse, 1L); assertHitCount(searchResponse, 1L);
assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().totalHits(), equalTo(1L));
@ -1186,7 +1187,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
searchResponse = client() searchResponse = client()
.filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD))) .filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
.prepareSearch("test") .prepareSearch("test")
.setQuery(hasChildQuery("child", termQuery("field1", "yellow"))) .setQuery(hasChildQuery("child", termQuery("field1", "yellow"), ScoreMode.None))
.get(); .get();
assertHitCount(searchResponse, 0L); assertHitCount(searchResponse, 0L);
} }