Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix : Business Attribute SearchableRef Search Depth #28

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,13 @@ private static Map<String, Object> getMappingForSearchableRefField(
.forEach(
entitySearchableRefFieldSpec ->
mappingForField.putAll(
getMappingForSearchableRefField(entitySearchableRefFieldSpec, depth - 1)));
getMappingForSearchableRefField(
entitySearchableRefFieldSpec,
Math.min(
depth - 1,
entitySearchableRefFieldSpec
.getSearchableRefAnnotation()
.getDepth()))));
mappingForField.put("urn", getMappingsForUrn());
mappingForProperty.put("properties", mappingForField);
mappings.put(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,14 @@ public static Set<SearchFieldConfig> detectSubFieldType(
aspectSpec.getSearchableRefFieldSpecs()) {
String refFieldName = searchableRefFieldSpec.getSearchableRefAnnotation().getFieldName();
refFieldName = fieldName + "." + refFieldName;
int newDepth =
Math.min(depth - 1, searchableRefFieldSpec.getSearchableRefAnnotation().getDepth());
final float refBoost =
(float) searchableRefFieldSpec.getSearchableRefAnnotation().getBoostScore()
* boostScore;
fieldConfigs.addAll(
detectSubFieldType(
searchableRefFieldSpec, depth - 1, entityRegistry, refBoost, refFieldName));
searchableRefFieldSpec, newDepth, entityRegistry, refBoost, refFieldName));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,9 +682,11 @@ public Map<String, SearchableAnnotation.FieldType> getAllFieldTypeFromSearchable
aspectSpec.getSearchableRefFieldSpecs()) {
String refFieldName = searchableRefFieldSpec.getSearchableRefAnnotation().getFieldName();
refFieldName = fieldName + "." + refFieldName;
int newDepth =
Math.min(depth - 1, searchableRefFieldSpec.getSearchableRefAnnotation().getDepth());
fieldNameMap.putAll(
getAllFieldTypeFromSearchableRef(
searchableRefFieldSpec, depth - 1, entityRegistry, refFieldName));
searchableRefFieldSpec, newDepth, entityRegistry, refFieldName));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,22 +502,23 @@ private Optional<JsonNode> getNodeForRef(
String fieldName = spec.getSearchableRefAnnotation().getFieldName();
boolean isArray = spec.isArray();
if (!value.isEmpty()) {
int newDepth = Math.min(depth - 1, spec.getSearchableRefAnnotation().getDepth());
if (isArray) {
ArrayNode arrayNode = JsonNodeFactory.instance.arrayNode();
value
.subList(0, Math.min(value.size(), maxArrayLength))
.forEach(
val ->
getNodeForRef(
depth - 1,
newDepth,
val,
spec.getSearchableRefAnnotation().getFieldType())
.ifPresent(arrayNode::add));
resultNode.set(fieldName, arrayNode);
} else {
Optional<JsonNode> node =
getNodeForRef(
depth - 1,
newDepth,
value.get(0),
spec.getSearchableRefAnnotation().getFieldType());
if (node.isPresent()) {
Expand Down