Skip to content
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<groupId>it.eng.dome</groupId>
<artifactId>search</artifactId>
<version>1.5.0</version>
<version>1.5.1</version>
<name>Search and Browsing</name>
<description>Demo for DOME Project</description>

Expand Down
4 changes: 4 additions & 0 deletions release_note.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

**Release Notes** for the *Search*:

### <code>1.5.1</code>
**Bug Fix**
* Data Normalization: Resolved an inconsistency in the normalization logic within the ResultProcessor. By ensuring uniform handling of strings (specifically case-insensitive transformation) during the retrieval phase, the system now guarantees accurate and predictable sorting for the name field.

### <code>1.5.0</code>
**Improvement**
* Dynamic Sorting: Implemented support for dynamic search result sorting. The SearchProduct and SearchProvider APIs now support sorting parameters via query string (e.g., ?sort=field,asc/desc).
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/it/eng/dome/search/config/IndexInitializer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package it.eng.dome.search.config;

import it.eng.dome.search.domain.IndexingObject;
import it.eng.dome.search.domain.ProviderIndex;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.elasticsearch.core.IndexOperations;
import org.springframework.data.elasticsearch.core.document.Document;

import javax.annotation.PostConstruct;

@Configuration
public class IndexInitializer {

private final ElasticsearchOperations elasticsearchOperations;
private final Logger logger = LoggerFactory.getLogger(IndexInitializer.class);

public IndexInitializer(ElasticsearchOperations elasticsearchOperations) {
this.elasticsearchOperations = elasticsearchOperations;
}

@PostConstruct
public void configureIndices() {
setupIndex(IndexingObject.class);
setupIndex(ProviderIndex.class);
}

private void setupIndex(Class<?> clazz) {
IndexOperations indexOps = elasticsearchOperations.indexOps(clazz);
if (!indexOps.exists()) {
String jsonSettings = "{\"analysis\": {\"normalizer\": {\"lowercase_normalizer\": {\"type\": \"custom\",\"filter\": [\"lowercase\"]}}}}";
indexOps.create(Document.parse(jsonSettings));
indexOps.putMapping(indexOps.createMapping(clazz));
logger.info("Indice per {} creato con normalizer personalizzato.", clazz.getSimpleName());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class IndexingObject {
@Field(type = FieldType.Text)
private String productOfferingDescription;

@Field(type = FieldType.Keyword)
@Field(type = FieldType.Keyword, normalizer = "lowercase_normalizer")
private String productOfferingName;

@Field(type = FieldType.Text)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/it/eng/dome/search/domain/ProviderIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ProviderIndex {
@Id
protected String id;

@Field(type = FieldType.Keyword)
@Field(type = FieldType.Keyword, normalizer = "lowercase_normalizer")
private String tradingName;

@Field(type = FieldType.Text)
Expand Down
Loading