use of org.hibernate.search.engine.backend.document.DocumentElement in project hibernate-search by hibernate.
the class DistanceSearchSortTypeCheckingAndConversionIT method initDocument.
private static void initDocument(IndexBinding indexBinding, DocumentElement document, Integer ordinal) {
addValue(indexBinding.fieldModel, document, ordinal);
addValue(indexBinding.fieldWithDslConverterModel, document, ordinal);
DocumentElement nested = document.addObject(indexBinding.nested.self);
addValue(indexBinding.nested.fieldModel, nested, ordinal);
addValue(indexBinding.nested.fieldWithDslConverterModel, nested, ordinal);
}
use of org.hibernate.search.engine.backend.document.DocumentElement in project hibernate-search by hibernate.
the class FieldSearchProjectionTypeCheckingAndConversionIT method initDocument.
private static <F> void initDocument(IndexBinding binding, DocumentElement document, int documentNumber) {
binding.fieldModels.forEach(f -> addFieldValue(document, f, documentNumber));
binding.fieldWithConverterModels.forEach(f -> addFieldValue(document, f, documentNumber));
// Note: this object must be single-valued for these tests
DocumentElement flattenedObject = document.addObject(binding.flattenedObject.self);
binding.flattenedObject.fieldModels.forEach(f -> addFieldValue(flattenedObject, f, documentNumber));
// Note: this object must be single-valued for these tests
DocumentElement nestedObject = document.addObject(binding.nestedObject.self);
binding.nestedObject.fieldModels.forEach(f -> addFieldValue(nestedObject, f, documentNumber));
}
use of org.hibernate.search.engine.backend.document.DocumentElement in project hibernate-search by hibernate.
the class DistanceSearchProjectionTypeCheckingAndConversionIT method initDocument.
private static <F> void initDocument(IndexBinding binding, DocumentElement document, int documentNumber) {
addFieldValue(document, binding.fieldModel, documentNumber);
addFieldValue(document, binding.fieldWithConverterModel, documentNumber);
// Note: this object must be single-valued for these tests
DocumentElement flattenedObject = document.addObject(binding.flattenedObject.self);
addFieldValue(flattenedObject, binding.flattenedObject.fieldModel, documentNumber);
// Note: this object must be single-valued for these tests
DocumentElement nestedObject = document.addObject(binding.nestedObject.self);
addFieldValue(nestedObject, binding.nestedObject.fieldModel, documentNumber);
}
use of org.hibernate.search.engine.backend.document.DocumentElement in project hibernate-search by hibernate.
the class FieldSearchSortTypeCheckingAndConversionIT method initDocument.
private static void initDocument(IndexBinding indexBinding, DocumentElement document, Integer ordinal) {
indexBinding.fieldModels.forEach(fieldModel -> addValue(fieldModel, document, ordinal));
indexBinding.fieldWithDslConverterModels.forEach(fieldModel -> addValue(fieldModel, document, ordinal));
DocumentElement nested = document.addObject(indexBinding.nested.self);
indexBinding.nested.fieldModels.forEach(fieldModel -> addValue(fieldModel, nested, ordinal));
indexBinding.nested.fieldWithDslConverterModels.forEach(fieldModel -> addValue(fieldModel, nested, ordinal));
}
use of org.hibernate.search.engine.backend.document.DocumentElement in project hibernate-search by hibernate.
the class ElasticsearchExtensionIT method initData.
private void initData() {
mainIndex.bulkIndexer().add(SECOND_ID, document -> {
document.addValue(mainIndex.binding().string, "text 2");
document.addValue(mainIndex.binding().nativeField_integer, new JsonPrimitive(2));
document.addValue(mainIndex.binding().nativeField_integer_converted, new JsonPrimitive(2));
document.addValue(mainIndex.binding().nativeField_unsupportedType, new JsonPrimitive("42"));
document.addValue(mainIndex.binding().nativeField_sort1, new JsonPrimitive("z"));
document.addValue(mainIndex.binding().nativeField_sort2, new JsonPrimitive("a"));
document.addValue(mainIndex.binding().nativeField_sort3, new JsonPrimitive("z"));
document.addValue(mainIndex.binding().nativeField_sort4, new JsonPrimitive("z"));
document.addValue(mainIndex.binding().nativeField_sort5, new JsonPrimitive("a"));
document.addValue(mainIndex.binding().nativeField_aggregation, new JsonPrimitive("value-for-doc-1-and-2"));
DocumentElement nestedObject1 = document.addObject(mainIndex.binding().nestedObject.self);
nestedObject1.addValue(mainIndex.binding().nestedObject.discriminator, "included");
nestedObject1.addValue(mainIndex.binding().nestedObject.sort1, "b");
nestedObject1.addValue(mainIndex.binding().nestedObject.aggregation1, "one");
DocumentElement nestedObject2 = document.addObject(mainIndex.binding().nestedObject.self);
nestedObject2.addValue(mainIndex.binding().nestedObject.discriminator, "excluded");
nestedObject2.addValue(mainIndex.binding().nestedObject.sort1, "a");
nestedObject2.addValue(mainIndex.binding().nestedObject.aggregation1, "fifty-one");
}).add(FIRST_ID, document -> {
document.addValue(mainIndex.binding().string, "text 1");
document.addValue(mainIndex.binding().nativeField_string, new JsonPrimitive("text 1"));
document.addValue(mainIndex.binding().nativeField_sort1, new JsonPrimitive("a"));
document.addValue(mainIndex.binding().nativeField_sort2, new JsonPrimitive("z"));
document.addValue(mainIndex.binding().nativeField_sort3, new JsonPrimitive("z"));
document.addValue(mainIndex.binding().nativeField_sort4, new JsonPrimitive("z"));
document.addValue(mainIndex.binding().nativeField_sort5, new JsonPrimitive("a"));
document.addValue(mainIndex.binding().nativeField_aggregation, new JsonPrimitive("value-for-doc-1-and-2"));
DocumentElement nestedObject1 = document.addObject(mainIndex.binding().nestedObject.self);
nestedObject1.addValue(mainIndex.binding().nestedObject.discriminator, "included");
nestedObject1.addValue(mainIndex.binding().nestedObject.sort1, "a");
nestedObject1.addValue(mainIndex.binding().nestedObject.aggregation1, "two");
DocumentElement nestedObject2 = document.addObject(mainIndex.binding().nestedObject.self);
nestedObject2.addValue(mainIndex.binding().nestedObject.discriminator, "excluded");
nestedObject2.addValue(mainIndex.binding().nestedObject.sort1, "b");
nestedObject2.addValue(mainIndex.binding().nestedObject.aggregation1, "fifty-two");
}).add(THIRD_ID, document -> {
document.addValue(mainIndex.binding().string, "text 3");
document.addValue(mainIndex.binding().nativeField_geoPoint, gson.fromJson("{'lat': 40.12, 'lon': -71.34}", JsonObject.class));
document.addValue(mainIndex.binding().nativeField_sort1, new JsonPrimitive("z"));
document.addValue(mainIndex.binding().nativeField_sort2, new JsonPrimitive("z"));
document.addValue(mainIndex.binding().nativeField_sort3, new JsonPrimitive("a"));
document.addValue(mainIndex.binding().nativeField_sort4, new JsonPrimitive("z"));
document.addValue(mainIndex.binding().nativeField_sort5, new JsonPrimitive("a"));
document.addValue(mainIndex.binding().nativeField_aggregation, new JsonPrimitive("value-for-doc-3"));
DocumentElement nestedObject1 = document.addObject(mainIndex.binding().nestedObject.self);
nestedObject1.addValue(mainIndex.binding().nestedObject.discriminator, "included");
nestedObject1.addValue(mainIndex.binding().nestedObject.sort1, "c");
nestedObject1.addValue(mainIndex.binding().nestedObject.aggregation1, "three");
DocumentElement nestedObject2 = document.addObject(mainIndex.binding().nestedObject.self);
nestedObject2.addValue(mainIndex.binding().nestedObject.discriminator, "excluded");
nestedObject2.addValue(mainIndex.binding().nestedObject.sort1, "b");
nestedObject2.addValue(mainIndex.binding().nestedObject.aggregation1, "fifty-three");
}).add(FOURTH_ID, document -> {
document.addValue(mainIndex.binding().string, "text 4");
document.addValue(mainIndex.binding().nativeField_dateWithColons, new JsonPrimitive("2018:01:12"));
document.addValue(mainIndex.binding().nativeField_sort1, new JsonPrimitive("z"));
document.addValue(mainIndex.binding().nativeField_sort2, new JsonPrimitive("z"));
document.addValue(mainIndex.binding().nativeField_sort3, new JsonPrimitive("z"));
document.addValue(mainIndex.binding().nativeField_sort4, new JsonPrimitive("a"));
document.addValue(mainIndex.binding().nativeField_sort5, new JsonPrimitive("a"));
DocumentElement nestedObject1 = document.addObject(mainIndex.binding().nestedObject.self);
nestedObject1.addValue(mainIndex.binding().nestedObject.discriminator, "included");
nestedObject1.addValue(mainIndex.binding().nestedObject.sort1, "d");
nestedObject1.addValue(mainIndex.binding().nestedObject.aggregation1, "four");
DocumentElement nestedObject2 = document.addObject(mainIndex.binding().nestedObject.self);
nestedObject2.addValue(mainIndex.binding().nestedObject.discriminator, "excluded");
nestedObject2.addValue(mainIndex.binding().nestedObject.sort1, "c");
nestedObject2.addValue(mainIndex.binding().nestedObject.aggregation1, "fifty-four");
}).add(FIFTH_ID, document -> {
document.addValue(mainIndex.binding().string, "text 5");
// This document should not match any query
document.addValue(mainIndex.binding().nativeField_string, new JsonPrimitive("text 2"));
document.addValue(mainIndex.binding().nativeField_integer, new JsonPrimitive(1));
document.addValue(mainIndex.binding().nativeField_geoPoint, gson.fromJson("{'lat': 45.12, 'lon': -75.34}", JsonObject.class));
document.addValue(mainIndex.binding().nativeField_dateWithColons, new JsonPrimitive("2018:01:25"));
// ignore_malformed is enabled, this should be ignored
document.addValue(mainIndex.binding().nativeField_unsupportedType, new JsonPrimitive("foobar"));
document.addValue(mainIndex.binding().nativeField_sort5, new JsonPrimitive("z"));
DocumentElement nestedObject1 = document.addObject(mainIndex.binding().nestedObject.self);
nestedObject1.addValue(mainIndex.binding().nestedObject.discriminator, "included");
nestedObject1.addValue(mainIndex.binding().nestedObject.sort1, "e");
nestedObject1.addValue(mainIndex.binding().nestedObject.aggregation1, "five");
DocumentElement nestedObject2 = document.addObject(mainIndex.binding().nestedObject.self);
nestedObject2.addValue(mainIndex.binding().nestedObject.discriminator, "excluded");
nestedObject2.addValue(mainIndex.binding().nestedObject.sort1, "a");
nestedObject2.addValue(mainIndex.binding().nestedObject.aggregation1, "fifty-five");
}).add(EMPTY_ID, document -> {
}).join();
}
Aggregations