Make facet and sort tests more reliable in case of multiple nodes and shards

Stats, histogram and range facets and sorting currently fail if a field that they are running on is not defined in the mapping. In case of dynamic fields it might mean that by the time the facet query is executed the new field mapping might not be propagated to all nodes yet.
This commit is contained in:
Igor Motov 2013-01-31 20:05:17 -05:00
parent 6a01e7882c
commit 3c9541dd14
2 changed files with 68 additions and 10 deletions

View File

@ -815,7 +815,14 @@ public class SimpleFacetsTests extends AbstractNodesTests {
} catch (Exception e) {
// ignore
}
client.admin().indices().prepareCreate("test").execute().actionGet();
// TODO: facet shouldn't fail when faceted field is mapped dynamically
// We have to specify mapping explicitly because by the time search is performed dynamic mapping might not
// be propagated to all nodes yet and some facets fail when the facet field is not defined
String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("num").field("type", "integer").endObject()
.startObject("multi_num").field("type", "float").endObject()
.endObject().endObject().endObject().string();
client.admin().indices().prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
client.prepareIndex("test", "type1").setSource(jsonBuilder().startObject()
@ -914,7 +921,11 @@ public class SimpleFacetsTests extends AbstractNodesTests {
} catch (Exception e) {
// ignore
}
client.admin().indices().prepareCreate("test").execute().actionGet();
// TODO: Make sure facet doesn't fail in case of dynamic mapping
String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("num").field("type", "integer").endObject()
.endObject().endObject().endObject().string();
client.admin().indices().prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
client.prepareIndex("test", "type1").setSource(jsonBuilder().startObject()
.field("num", 100)
@ -960,7 +971,13 @@ public class SimpleFacetsTests extends AbstractNodesTests {
} catch (Exception e) {
// ignore
}
client.admin().indices().prepareCreate("test").execute().actionGet();
// TODO: facet shouldn't fail when faceted field is mapped dynamically
String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("num").field("type", "integer").endObject()
.startObject("multi_num").field("type", "float").endObject()
.startObject("date").field("type", "date").endObject()
.endObject().endObject().endObject().string();
client.admin().indices().prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
client.prepareIndex("test", "type1").setSource(jsonBuilder().startObject()
@ -1207,7 +1224,15 @@ public class SimpleFacetsTests extends AbstractNodesTests {
} catch (Exception e) {
// ignore
}
client.admin().indices().prepareCreate("test").execute().actionGet();
// TODO: facet shouldn't fail when faceted field is mapped dynamically
String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("num").field("type", "integer").endObject()
.startObject("multi_num").field("type", "float").endObject()
.startObject("value").field("type", "integer").endObject()
.startObject("multi_value").field("type", "float").endObject()
.startObject("date").field("type", "date").endObject()
.endObject().endObject().endObject().string();
client.admin().indices().prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
client.prepareIndex("test", "type1").setSource(jsonBuilder().startObject()
@ -1367,7 +1392,12 @@ public class SimpleFacetsTests extends AbstractNodesTests {
} catch (Exception e) {
// ignore
}
client.admin().indices().prepareCreate("test").execute().actionGet();
// TODO: facet shouldn't fail when faceted field is mapped dynamically
String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("num").field("type", "integer").endObject()
.startObject("date").field("type", "date").endObject()
.endObject().endObject().endObject().string();
client.admin().indices().prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
client.prepareIndex("test", "type1").setSource(jsonBuilder().startObject()
@ -1481,7 +1511,12 @@ public class SimpleFacetsTests extends AbstractNodesTests {
} catch (Exception e) {
// ignore
}
client.admin().indices().prepareCreate("test").execute().actionGet();
// TODO: facet shouldn't fail when faceted field is mapped dynamically
String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("num").field("type", "integer").endObject()
.startObject("date").field("type", "date").endObject()
.endObject().endObject().endObject().string();
client.admin().indices().prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
client.prepareIndex("test", "type1").setSource(jsonBuilder().startObject()
@ -1547,7 +1582,13 @@ public class SimpleFacetsTests extends AbstractNodesTests {
} catch (Exception e) {
// ignore
}
client.admin().indices().prepareCreate("test").execute().actionGet();
// TODO: facet shouldn't fail when faceted field is mapped dynamically
String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("field").field("type", "string").endObject()
.startObject("num").field("type", "integer").endObject()
.startObject("multi_num").field("type", "float").endObject()
.endObject().endObject().endObject().string();
client.admin().indices().prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
client.prepareIndex("test", "type1").setSource(jsonBuilder().startObject()
@ -1731,7 +1772,14 @@ public class SimpleFacetsTests extends AbstractNodesTests {
} catch (Exception e) {
// ignore
}
client.admin().indices().prepareCreate("test").execute().actionGet();
// TODO: facet shouldn't fail when faceted field is mapped dynamically
String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("lField").field("type", "long").endObject()
.startObject("dField").field("type", "double").endObject()
.startObject("num").field("type", "float").endObject()
.startObject("multi_num").field("type", "integer").endObject()
.endObject().endObject().endObject().string();
client.admin().indices().prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
client.prepareIndex("test", "type1").setSource(jsonBuilder().startObject()
@ -1804,7 +1852,11 @@ public class SimpleFacetsTests extends AbstractNodesTests {
} catch (Exception e) {
// ignore
}
client.admin().indices().prepareCreate("test").execute().actionGet();
// TODO: facet shouldn't fail when faceted field is mapped dynamically
String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("num").field("type", "float").endObject()
.endObject().endObject().endObject().string();
client.admin().indices().prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
for (int i = 0; i < 20; i++) {

View File

@ -431,7 +431,13 @@ public class SimpleSortTests extends AbstractNodesTests {
} catch (Exception e) {
// ignore
}
client.admin().indices().prepareCreate("test").execute().actionGet();
// TODO: sort shouldn't fail when sort field is mapped dynamically
// We have to specify mapping explicitly because by the time search is performed dynamic mapping might not
// be propagated to all nodes yet and sort operation fail when the sort field is not defined
String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("svalue").field("type", "string").endObject()
.endObject().endObject().endObject().string();
client.admin().indices().prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
client.prepareIndex("test", "type1").setSource(jsonBuilder().startObject()