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

UFAL/Autocomplete enhancement #768

Merged
merged 29 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ab2d7c0
Added solr index `handle_title_ac` and `_comp` for the Item
milanmajchrak Sep 19, 2024
c9f56eb
Added support for searching results from specific solr indexes.
milanmajchrak Sep 20, 2024
7e357a4
Supported searching Item byHandle when passed a handle as parameter w…
milanmajchrak Sep 24, 2024
3dae319
Added autocompleteCustom `solr-subject_ac` and `handle_title_ac`.
milanmajchrak Sep 24, 2024
807400c
Added autocompleteCustom `solr-publisher_ac`.
milanmajchrak Sep 24, 2024
c10fdb7
Added cfg property to define a separator from the solr value to get o…
milanmajchrak Sep 24, 2024
05f6fe4
Added autocompleteCustom `solr-dataProvider_ac`
milanmajchrak Sep 24, 2024
8655cdc
Refactored code and created integration test for the SuggestionRestCo…
milanmajchrak Sep 24, 2024
e542465
Fixed conflicts and checkstyle issues
milanmajchrak Sep 24, 2024
3ef7de7
Merge branch 'dtq-dev' into ufal/autocomplete-enhancement
milanmajchrak Sep 24, 2024
920a7d4
Updated suggestion integration tests because it has had a conflict wi…
milanmajchrak Sep 24, 2024
8de895c
Merge branch 'ufal/autocomplete-enhancement' of github.com:dataquest-…
milanmajchrak Sep 24, 2024
ae27d91
Added doc and changed `autocomplete.custom.format` to `autocomplete.c…
milanmajchrak Sep 24, 2024
a9e1b6c
Added support for loading suggestions from the json file - need to re…
milanmajchrak Sep 25, 2024
e453656
Refactored and added docs.
milanmajchrak Sep 26, 2024
154363a
Fixed checkstyle issue
milanmajchrak Sep 26, 2024
2f6c227
Created tests and fixed failing ones due to updated solr definition
milanmajchrak Sep 26, 2024
888b603
Fixed checkstyle issues
milanmajchrak Sep 26, 2024
adb92cd
Synchronized submission-forms_cs.xml with the original-english one
milanmajchrak Sep 27, 2024
2dc2872
Added docs about magic constants
milanmajchrak Sep 27, 2024
ce07684
Added doc why the handle is updated to canonical form in the searchby…
milanmajchrak Oct 11, 2024
21d00b2
Allow searching only within the solr indexes or JSON files permitted …
milanmajchrak Nov 4, 2024
ff983b3
Removed normalization of handle prefix because there could be more pr…
milanmajchrak Nov 4, 2024
99b9df9
Fixed conflicts
milanmajchrak Nov 4, 2024
1d81001
Fixed if condition and config property default value.
milanmajchrak Nov 4, 2024
967734c
Fixed integration tests. Allowed autocomplete custom was missing in t…
milanmajchrak Nov 5, 2024
e6b0756
The suggestion endpoint is allowed only for authorized users
milanmajchrak Nov 18, 2024
3f49113
Refactored method for the normalizing the query for the discoverQuery…
milanmajchrak Nov 18, 2024
b4d7b65
Fixed checkstyle issues
milanmajchrak Nov 18, 2024
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
16 changes: 16 additions & 0 deletions dspace-api/src/main/java/org/dspace/app/util/DCInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ public class DCInput {
*/
private ComplexDefinition complexDefinition = null;

/**
* give suggestions from this specific autocomplete solr index/file
*/
private String autocompleteCustom = null;

/**
* the dropdown input type could have defined a default value
*/
Expand Down Expand Up @@ -234,6 +239,9 @@ public DCInput(Map<String, String> fieldMap, Map<String, List<String>> listMap,
if ("complex".equals(inputType)) {
complexDefinition = complexDefinitions.getByName((fieldMap.get(DCInputsReader.COMPLEX_DEFINITION_REF)));
}
if ("autocomplete".equals(inputType)) {
autocompleteCustom = fieldMap.get(DCInputsReader.AUTOCOMPLETE_CUSTOM);
vidiecan marked this conversation as resolved.
Show resolved Hide resolved
}
hint = fieldMap.get("hint");
warning = fieldMap.get("required");
required = warning != null && warning.length() > 0;
Expand Down Expand Up @@ -701,6 +709,14 @@ public boolean isMetadataField() {
return isMetadataField;
}

public String getAutocompleteCustom() {
return autocompleteCustom;
}

public void setAutocompleteCustom(String autocompleteCustom) {
this.autocompleteCustom = autocompleteCustom;
}

/**
* Class representing a Map of the ComplexDefinition object
* Class is copied from UFAL/CLARIN-DSPACE (https://github.com/ufal/clarin-dspace) and modified by
Expand Down
10 changes: 10 additions & 0 deletions dspace-api/src/main/java/org/dspace/app/util/DCInputsReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ public class DCInputsReader {
*/
static final String COMPLEX_DEFINITION_REF = "complex-definition-ref";

/**
* Keyname for storing the name of the custom autocomplete input type
*/
static final String AUTOCOMPLETE_CUSTOM = "autocomplete-custom";


/**
* Reference to the forms definitions map, computed from the forms
Expand Down Expand Up @@ -551,6 +556,11 @@ private void handleInputTypeTagName(String formName, Map<String, String> field,
} else {
field.put(COMPLEX_DEFINITION_REF, definitionName);
}
} else if (value.equals("autocomplete")) {
String definitionName = getAttribute(nd, AUTOCOMPLETE_CUSTOM);
if (definitionName != null) {
field.put(AUTOCOMPLETE_CUSTOM, definitionName);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,28 @@ public void addDiscoveryFields(SolrInputDocument doc, Context context, Item item
}



vidiecan marked this conversation as resolved.
Show resolved Hide resolved
// process item metadata
// just add _comp to local*
List<MetadataValue> mds = itemService.getMetadata(item, "local", Item.ANY, Item.ANY, Item.ANY);
for (MetadataValue meta : mds) {
String field = "local" + "." + meta.getMetadataField().getElement();
String value = meta.getValue();
if (value == null) {
continue;
}
String qualifier = meta.getMetadataField().getQualifier();
if (qualifier != null && !qualifier.isEmpty()) {
field += "." + qualifier;
}
doc.addField(field + "_comp", value);
}

// create handle_title_ac field
String title = item.getName();
String handle = item.getHandle();
doc.addField("handle_title_ac", handle + ":" + title);

log.debug(" Added Metadata");

try {
Expand Down
Loading
Loading